Exemplo n.º 1
0
bool
ReadWaypointFile(Path path, Waypoints &way_points,
                 WaypointFactory factory, OperationEnvironment &operation)
{
  return ReadWaypointFile(path, DetermineWaypointFileType(path),
                          way_points, factory, operation);
}
Exemplo n.º 2
0
void
WaypointReader::Open(const TCHAR* filename, int the_filenum)
{
  delete reader;
  reader = NULL;

  // If filename is empty -> clear and return NULL pointer
  if (StringIsEmpty(filename))
    return;

  // Test if file exists
  bool compressed = false;
  if (!File::Exists(filename)) {
    compressed = true;
    // Test if file exists in zip archive
    ZipSource zip(filename);
    if (zip.error())
      // If the file doesn't exist return NULL pointer
      return;
  }

  switch (DetermineWaypointFileType(filename)) {
  case WaypointFileType::WINPILOT:
    reader = new WaypointReaderWinPilot(filename, the_filenum, compressed);
    break;

  case WaypointFileType::SEEYOU:
    reader = new WaypointReaderSeeYou(filename, the_filenum, compressed);
    break;

  case WaypointFileType::ZANDER:
    reader = new WaypointReaderZander(filename, the_filenum, compressed);
    break;

  case WaypointFileType::FS:
    reader = new WaypointReaderFS(filename, the_filenum, compressed);
    break;

  case WaypointFileType::OZI_EXPLORER:
    reader = new WaypointReaderOzi(filename, the_filenum, compressed);
    break;

  case WaypointFileType::COMPE_GPS:
    reader = new WaypointReaderCompeGPS(filename, the_filenum, compressed);
    break;

  default:
    break;
  }
}
Exemplo n.º 3
0
bool
WaypointGlue::SaveWaypointFile(const Waypoints &way_points, int num)
{
  if (!IsWritable(num)) {
    LogFormat("Waypoint file %d can not be written", num);
    return false;
  }

  TCHAR file[255];
  GetPath(num, file);

  TextWriter writer(file);
  if (!writer.IsOpen()) {
    LogFormat("Waypoint file %d can not be written", num);
    return false;
  }

  WaypointWriter wp_writer(way_points, num);
  wp_writer.Save(writer, DetermineWaypointFileType(file));

  LogFormat("Waypoint file %d saved", num);
  return true;
}