diff options
author | erorcun <erayorcunus@gmail.com> | 2020-07-28 17:33:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-28 17:33:27 +0200 |
commit | 3d91d4fc6ae31da9c3c93455e1f6e3eea8d8eef5 (patch) | |
tree | 5805f0a7f60da9ba4acd0e60700f0418c1f01188 /src/core/FileMgr.cpp | |
parent | Merge pull request #665 from erorcun/miami (diff) | |
parent | Fix casepath chaos (diff) | |
download | re3-3d91d4fc6ae31da9c3c93455e1f6e3eea8d8eef5.tar re3-3d91d4fc6ae31da9c3c93455e1f6e3eea8d8eef5.tar.gz re3-3d91d4fc6ae31da9c3c93455e1f6e3eea8d8eef5.tar.bz2 re3-3d91d4fc6ae31da9c3c93455e1f6e3eea8d8eef5.tar.lz re3-3d91d4fc6ae31da9c3c93455e1f6e3eea8d8eef5.tar.xz re3-3d91d4fc6ae31da9c3c93455e1f6e3eea8d8eef5.tar.zst re3-3d91d4fc6ae31da9c3c93455e1f6e3eea8d8eef5.zip |
Diffstat (limited to 'src/core/FileMgr.cpp')
-rw-r--r-- | src/core/FileMgr.cpp | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index cdcb80f0..4477a190 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -4,6 +4,7 @@ #include <direct.h> #endif #include "common.h" +#include "crossplatform.h" #include "FileMgr.h" @@ -31,19 +32,16 @@ static myFILE myfiles[NUMFILES]; #include <dirent.h> #include <errno.h> #include <unistd.h> -#include "crossplatform.h" #define _getcwd getcwd // Case-insensitivity on linux (from https://github.com/OneSadCookie/fcaseopen) void mychdir(char const *path) { - char *r = (char*)alloca(strlen(path) + 2); - if (casepath(path, r)) - { + char* r = casepath(path, false); + if (r) { chdir(r); - } - else - { + free(r); + } else { errno = ENOENT; } } @@ -73,30 +71,7 @@ found: *p++ = 'b'; *p = '\0'; -#if !defined(_WIN32) - char *newPath = strdup(filename); - // Normally casepath() fixes backslashes, but if the mode is sth other than r/rb it will create new file with backslashes on linux, so fix backslashes here - char *nextBs; - while(nextBs = strstr(newPath, "\\")){ - *nextBs = '/'; - } -#else - const char *newPath = filename; -#endif - - myfiles[fd].file = fopen(newPath, realmode); -// Be case-insensitive on linux (from https://github.com/OneSadCookie/fcaseopen/) -#if !defined(_WIN32) - if (!myfiles[fd].file) { - char *r = (char*)alloca(strlen(newPath) + 2); - if (casepath(newPath, r)) - { - myfiles[fd].file = fopen(r, realmode); - } - } - - free(newPath); -#endif + myfiles[fd].file = fcaseopen(filename, realmode); if(myfiles[fd].file == nil) return 0; return fd; |