Beispiel #1
0
TLineReader *
OpenTextFile(const TCHAR *path, ConvertLineReader::charset cs)
{
  assert(path != NULL);

  FileLineReader *reader = new FileLineReader(path, cs);
  if (reader == NULL)
    return NULL;

  if (!reader->error())
    return reader;

  delete reader;

  ZipLineReader *zip_reader = new ZipLineReader(path, cs);
  if (zip_reader == NULL)
    return NULL;

  if (!zip_reader->error())
    return zip_reader;

  delete zip_reader;

  return NULL;
}
Beispiel #2
0
int LoadScript(int i, int import) {
	// Already tried.
	if (files[i].loaded != -1) return 3;
	unsigned char *temp2 = UTF16toUTF8Alloc(files[i].name);
	if (!import)
		errorPrintf(2, "Compiling: %s\r\n", temp2);
	else
		errorPrintf(2, "Compiling (imported): %s\r\n", temp2);
	if (!temp2) {
		errorPrintf(2, "Error Loading: %s\r\n", temp2);
		errors++;
		return 0;
	}
	int res = 0;
	FileLineReader *reader = OpenLineReader(files[i].name, 0, WHOLE_FILE);
	if (reader) {
		unsigned char *data;
		int len = reader->NextLine(&data);
		files[i].loaded = 2;
		if (data) {
			res = Compile(data, len, temp2, files[i].name);
			files[i].loaded = res;
		}
		delete reader;
	}
	else {
		errorPrintf(2, "\r\nError Loading: %s\r\n\r\n", temp2);
		errors++;
		return 0;
	}
	//	free(temp);
	//}
	free(temp2);
	return res;
}
Beispiel #3
0
/**
 * Parses Options and OZs from See You task file
 * @param reader.  Points to first line of task after task "Waypoint list" line
 * @param task_info Loads this with CU task options info
 * @param turnpoint_infos Loads this with CU task tp info
 */
static void
ParseCUTaskDetails(FileLineReader &reader, SeeYouTaskInformation *task_info,
                   SeeYouTurnpointInformation turnpoint_infos[])
{
  // Read options/observation zones
  TCHAR params_buffer[1024];
  const TCHAR *params[20];
  TCHAR *line;
  int TPIndex = 0;
  const unsigned int max_params = ARRAY_SIZE(params);
  while ((line = reader.ReadLine()) != NULL &&
         line[0] != _T('\"') && line[0] != _T(',')) {
    const size_t n_params = WaypointReaderBase::
        ExtractParameters(line, params_buffer, params, max_params, true);

    if (_tcscmp(params[0], _T("Options")) == 0) {
      // Options line found
      ParseOptions(task_info, params, n_params);

    } else if (_tcsncmp(params[0], _T("ObsZone"), 7) == 0) {
      // Observation zone line found
      if (_tcslen(params[0]) <= 8)
        continue;

      TPIndex = ParseOZs(turnpoint_infos, params, n_params);
      if (TPIndex == 0)
        task_info->max_start_altitude = turnpoint_infos[TPIndex].max_altitude;
    }
  } // end while
}
Beispiel #4
0
TLineReader *
OpenDataTextFile(const TCHAR *name, Error &error, Charset cs)
{
  assert(name != nullptr);
  assert(!StringIsEmpty(name));

  const auto path = LocalPath(name);

  FileLineReader *reader = new FileLineReader(path, error, cs);
  if (reader->error()) {
    delete reader;
    return nullptr;
  }

  return reader;
}
Beispiel #5
0
TLineReader *
OpenConfiguredTextFile(const char *profile_key, ConvertLineReader::charset cs)
{
  assert(profile_key != NULL);

  TCHAR path[MAX_PATH];
  if (!Profile::GetPath(profile_key, path))
    return NULL;

  FileLineReader *reader = new FileLineReader(path, cs);
  if (reader == NULL)
    return NULL;

  if (reader->error()) {
    delete reader;
    return NULL;
  }

  return reader;
}
Beispiel #6
0
TLineReader *
OpenConfiguredTextFile(const char *profile_key, Charset cs)
{
  assert(profile_key != nullptr);

  TCHAR path[MAX_PATH];
  if (!Profile::GetPath(profile_key, path))
    return nullptr;

  Error error;
  FileLineReader *reader = new FileLineReader(path, error, cs);
  if (reader == nullptr) {
    LogError(error);
    return nullptr;
  }

  if (reader->error()) {
    delete reader;
    return nullptr;
  }

  return reader;
}
Beispiel #7
0
TLineReader *
OpenConfiguredTextFile(const char *profile_key, Charset cs)
{
  assert(profile_key != nullptr);

  const auto path = Profile::GetPath(profile_key);
  if (path.IsNull())
    return nullptr;

  Error error;
  FileLineReader *reader = new FileLineReader(path, error, cs);
  if (reader == nullptr) {
    LogError(error);
    return nullptr;
  }

  if (reader->error()) {
    delete reader;
    return nullptr;
  }

  return reader;
}
Beispiel #8
0
TLineReader *
OpenDataTextFile(const TCHAR *name, ConvertLineReader::charset cs)
{
#ifdef _UNICODE
  assert(name != NULL);
  assert(!StringIsEmpty(name));

  TCHAR path[MAX_PATH];
  LocalPath(path, name);

  FileLineReader *reader = new FileLineReader(path, cs);
  if (reader == NULL)
    return NULL;

  if (reader->error()) {
    delete reader;
    return NULL;
  }

  return reader;
#else
  return OpenDataTextFileA(name);
#endif
}