Browse Source

Don't use the HOME directory as the espeak-ng-data path.

master
Reece H. Dunn 8 years ago
parent
commit
d42ba93959
1 changed files with 9 additions and 6 deletions
  1. 9
    6
      src/libespeak-ng/speech.c

+ 9
- 6
src/libespeak-ng/speech.c View File



#endif #endif


static int check_data_path(const char *path)
static int check_data_path(const char *path, int allow_directory)
{ {
if (!path) return 0; if (!path) return 0;


if (GetFileLength(path_home) == -2) if (GetFileLength(path_home) == -2)
return 1; return 1;


if (!allow_directory)
return 0;

snprintf(path_home, sizeof(path_home), "%s", path); snprintf(path_home, sizeof(path_home), "%s", path);
return GetFileLength(path_home) == -2; return GetFileLength(path_home) == -2;
} }


ESPEAK_NG_API void espeak_ng_InitializePath(const char *path) ESPEAK_NG_API void espeak_ng_InitializePath(const char *path)
{ {
if (check_data_path(path))
if (check_data_path(path, 1))
return; return;


#ifdef PLATFORM_WINDOWS #ifdef PLATFORM_WINDOWS
unsigned long var_type; unsigned long var_type;
unsigned char buf[sizeof(path_home)-13]; unsigned char buf[sizeof(path_home)-13];


if (check_data_path(getenv("ESPEAK_DATA_PATH")))
if (check_data_path(getenv("ESPEAK_DATA_PATH"), 1))
return; return;


buf[0] = 0; buf[0] = 0;
var_type = REG_SZ; var_type = REG_SZ;
RegQueryValueExA(RegKey, "Path", 0, &var_type, buf, &size); RegQueryValueExA(RegKey, "Path", 0, &var_type, buf, &size);


if (check_data_path(buf))
if (check_data_path(buf, 1))
return; return;
#elif !defined(PLATFORM_DOS) #elif !defined(PLATFORM_DOS)
if (check_data_path(getenv("ESPEAK_DATA_PATH")))
if (check_data_path(getenv("ESPEAK_DATA_PATH"), 1))
return; return;


if (check_data_path(getenv("HOME")))
if (check_data_path(getenv("HOME"), 0))
return; return;
#endif #endif



Loading…
Cancel
Save