equal
deleted
inserted
replaced
412 bool FileExists(const char *filename) |
412 bool FileExists(const char *filename) |
413 { |
413 { |
414 return access(filename, 0) == 0; |
414 return access(filename, 0) == 0; |
415 } |
415 } |
416 |
416 |
417 static int LanguageCompareFunc(const void *a, const void *b) |
|
418 { |
|
419 return strcmp(*(const char* const *)a, *(const char* const *)b); |
|
420 } |
|
421 |
|
422 int GetLanguageList(char **languages, int max) |
|
423 { |
|
424 DIR *dir; |
|
425 struct dirent *dirent; |
|
426 int num = 0; |
|
427 |
|
428 dir = opendir(_path.lang_dir); |
|
429 if (dir != NULL) { |
|
430 while ((dirent = readdir(dir)) != NULL) { |
|
431 char *t = strrchr(dirent->d_name, '.'); |
|
432 |
|
433 if (t != NULL && strcmp(t, ".lng") == 0) { |
|
434 languages[num++] = strdup(dirent->d_name); |
|
435 if (num == max) break; |
|
436 } |
|
437 } |
|
438 closedir(dir); |
|
439 } |
|
440 |
|
441 qsort(languages, num, sizeof(char*), LanguageCompareFunc); |
|
442 return num; |
|
443 } |
|
444 |
|
445 #if defined(__BEOS__) || defined(__linux__) |
417 #if defined(__BEOS__) || defined(__linux__) |
446 static void ChangeWorkingDirectory(char *exe) |
418 static void ChangeWorkingDirectory(char *exe) |
447 { |
419 { |
448 char *s = strrchr(exe, '/'); |
420 char *s = strrchr(exe, '/'); |
449 if (s != NULL) { |
421 if (s != NULL) { |