} | } | ||||
length = GetFileLength(fname); | length = GetFileLength(fname); | ||||
if (length < 0) { // length == -errno | |||||
fclose(f); | |||||
return create_file_error_context(context, -length, fname); | |||||
} | |||||
if (fseek(f, 0, SEEK_SET) == -1) { | if (fseek(f, 0, SEEK_SET) == -1) { | ||||
int error = errno; | int error = errno; | ||||
fclose(f); | fclose(f); |
if (!path) return 0; | if (!path) return 0; | ||||
snprintf(path_home, sizeof(path_home), "%s/espeak-ng-data", path); | snprintf(path_home, sizeof(path_home), "%s/espeak-ng-data", path); | ||||
if (GetFileLength(path_home) == -2) | |||||
if (GetFileLength(path_home) == -EISDIR) | |||||
return 1; | return 1; | ||||
if (!allow_directory) | if (!allow_directory) | ||||
return 0; | 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) == -EISDIR; | |||||
} | } | ||||
#pragma GCC visibility push(default) | #pragma GCC visibility push(default) | ||||
return 0; | return 0; | ||||
if (S_ISDIR(statbuf.st_mode)) | if (S_ISDIR(statbuf.st_mode)) | ||||
return -2; // a directory | |||||
return -EISDIR; | |||||
return statbuf.st_size; | return statbuf.st_size; | ||||
} | } |
// read eSpeak's mbrola phoneme translation data, eg. en1_phtrans | // read eSpeak's mbrola phoneme translation data, eg. en1_phtrans | ||||
sprintf(path, "%s/mbrola_ph/%s", path_home, phtrans); | sprintf(path, "%s/mbrola_ph/%s", path_home, phtrans); | ||||
size = GetFileLength(path); | size = GetFileLength(path); | ||||
if (size < 0) // size == -errno | |||||
return -size; | |||||
if ((f_in = fopen(path, "rb")) == NULL) { | if ((f_in = fopen(path, "rb")) == NULL) { | ||||
int error = errno; | int error = errno; | ||||
close_MBR(); | close_MBR(); |
sprintf(buf, "%s%c%s", path_home, PATHSEP, fname); | sprintf(buf, "%s%c%s", path_home, PATHSEP, fname); | ||||
length = GetFileLength(buf); | length = GetFileLength(buf); | ||||
if (length < 0) // length == -errno | |||||
return create_file_error_context(context, -length, buf); | |||||
if ((f_in = fopen(buf, "rb")) == NULL) | if ((f_in = fopen(buf, "rb")) == NULL) | ||||
return create_file_error_context(context, errno, buf); | return create_file_error_context(context, errno, buf); |
#include "config.h" | #include "config.h" | ||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <errno.h> | |||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
} | } | ||||
sprintf(buf, "%s/voices/%s", path_home, language); | sprintf(buf, "%s/voices/%s", path_home, language); | ||||
if (GetFileLength(buf) == -2) { | |||||
if (GetFileLength(buf) == -EISDIR) { | |||||
// A subdirectory name has been specified. List all the voices in that subdirectory | // A subdirectory name has been specified. List all the voices in that subdirectory | ||||
language[lang_len++] = PATHSEP; | language[lang_len++] = PATHSEP; | ||||
language[lang_len] = 0; | language[lang_len] = 0; | ||||
sprintf(fname, "%s%c%s", path, PATHSEP, FindFileData.cFileName); | sprintf(fname, "%s%c%s", path, PATHSEP, FindFileData.cFileName); | ||||
ftype = GetFileLength(fname); | ftype = GetFileLength(fname); | ||||
if (ftype == -2) { | |||||
// a sub-sirectory | |||||
if (ftype == -EISDIR) { | |||||
// a sub-directory | |||||
GetVoices(fname); | GetVoices(fname); | ||||
} else if (ftype > 0) { | } else if (ftype > 0) { | ||||
// a regular line, add it to the voices list | |||||
// a regular file, add it to the voices list | |||||
if ((f_voice = fopen(fname, "r")) == NULL) | if ((f_voice = fopen(fname, "r")) == NULL) | ||||
continue; | continue; | ||||
ftype = GetFileLength(fname); | ftype = GetFileLength(fname); | ||||
if (ftype == -2) { | |||||
// a sub-sirectory | |||||
if (ftype == -EISDIR) { | |||||
// a sub-directory | |||||
GetVoices(fname); | GetVoices(fname); | ||||
} else if (ftype > 0) { | } else if (ftype > 0) { | ||||
// a regular line, add it to the voices list | |||||
// a regular file, add it to the voices list | |||||
if ((f_voice = fopen(fname, "r")) == NULL) | if ((f_voice = fopen(fname, "r")) == NULL) | ||||
continue; | continue; | ||||