MCPcopy Create free account
hub / github.com/VerySleepy/verysleepy / Parse

Function Parse

src/utils/stringutils.cpp:311–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309
310template<typename T>
311static void Parse(const wchar_t *file, T* dst)
312{
313 FILE *fp;
314 wchar_t path[MAX_PATH];
315 wcscpy(path, file);
316
317 fp = _wfopen(path, L"r");
318
319 if (!fp) {
320 GetModuleFileName(NULL, path, MAX_PATH);
321 PathRemoveFileSpec(path);
322
323 do
324 {
325 PathAppend(path, file);
326 fp = _wfopen(path, L"r");
327 }
328 while (!fp && PathRemoveFileSpec(path) && PathRemoveFileSpec(path));
329 }
330
331 if (!fp)
332 return;
333
334 wchar_t line[4096];
335 while(fgetws(line, 4096, fp))
336 {
337 wchar_t *start = line;
338 while(*start && isspace(*start))
339 start++;
340
341 if (*start == 0)
342 continue;
343
344 wchar_t *end = line+wcslen(line)-1;
345 while(end != start && isspace(*end))
346 *end-- = 0;
347
348 dst->Add(start);
349 }
350 fclose(fp);
351}
352
353StringSet::StringSet(const wchar_t *file, bool caseCheck)
354{

Callers 2

StringSetMethod · 0.85
StringListMethod · 0.85

Calls 1

AddMethod · 0.80

Tested by

no test coverage detected