Search more paths for different build situations

This commit is contained in:
miloyip
2015-04-14 10:35:45 +08:00
parent 3f7a3bcc04
commit 3675b33a2a
4 changed files with 64 additions and 33 deletions

View File

@@ -47,14 +47,21 @@ private:
protected:
static FILE* Open(const char* filename) {
const char *paths[] = {
"encodings/%s",
"bin/encodings/%s",
"../bin/encodings/%s",
"../../bin/encodings/%s",
"../../../bin/encodings/%s"
};
char buffer[1024];
sprintf(buffer, "encodings/%s", filename);
FILE *fp = fopen(buffer, "rb");
if (!fp) {
sprintf(buffer, "../../bin/encodings/%s", filename);
fp = fopen(buffer, "rb");
for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
sprintf(buffer, paths[i], filename);
FILE *fp = fopen(buffer, "rb");
if (fp)
return fp;
}
return fp;
return 0;
}
static char *ReadFile(const char* filename, bool appendPath, size_t* outLength) {