diff options
author | eray orçunus <erayorcunus@gmail.com> | 2020-10-12 19:47:34 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2020-10-12 19:47:34 +0200 |
commit | 342da2430b5e0ca6ccc278c32ff104e1cfdb4113 (patch) | |
tree | 3285d50a4a687252b31c965afcde3a5a7a0d5cdc /src/skel | |
parent | SampleManager (diff) | |
parent | Streaming and cross-platform fixes (diff) | |
download | re3-342da2430b5e0ca6ccc278c32ff104e1cfdb4113.tar re3-342da2430b5e0ca6ccc278c32ff104e1cfdb4113.tar.gz re3-342da2430b5e0ca6ccc278c32ff104e1cfdb4113.tar.bz2 re3-342da2430b5e0ca6ccc278c32ff104e1cfdb4113.tar.lz re3-342da2430b5e0ca6ccc278c32ff104e1cfdb4113.tar.xz re3-342da2430b5e0ca6ccc278c32ff104e1cfdb4113.tar.zst re3-342da2430b5e0ca6ccc278c32ff104e1cfdb4113.zip |
Diffstat (limited to 'src/skel')
-rw-r--r-- | src/skel/crossplatform.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index 697f9006..ac4bbe85 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -27,13 +27,28 @@ void GetLocalTime_CP(SYSTEMTIME *out) { #ifndef _WIN32 HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) { char newpathname[32]; + strncpy(newpathname, pathname, 32); - char* path = strtok(newpathname, "\\*"); + char* path = strtok(newpathname, "*"); + + // Case-sensitivity and backslashes... + char *real = casepath(path); + if (real) { + real[strlen(real)] = '*'; + char *extension = strtok(NULL, "*"); + if (extension) + strcat(real, extension); + + strncpy(newpathname, real, 32); + free(real); + path = strtok(newpathname, "*"); + } + strncpy(firstfile->folder, path, sizeof(firstfile->folder)); // Both w/ extension and w/o extension is ok - if (strlen(path) + 2 != strlen(pathname)) - strncpy(firstfile->extension, strtok(NULL, "\\*"), sizeof(firstfile->extension)); + if (strlen(path) + 1 != strlen(pathname)) + strncpy(firstfile->extension, strtok(NULL, "*"), sizeof(firstfile->extension)); else strncpy(firstfile->extension, "", sizeof(firstfile->extension)); @@ -53,7 +68,7 @@ bool FindNextFile(HANDLE d, WIN32_FIND_DATA* finddata) { // We only want "DT_REG"ular Files, but reportedly some FS and OSes gives DT_UNKNOWN as type. if ((file->d_type == DT_UNKNOWN || file->d_type == DT_REG || file->d_type == DT_LNK) && - (extensionLen == 0 || strncmp(&file->d_name[strlen(file->d_name) - extensionLen], finddata->extension, extensionLen) == 0)) { + (extensionLen == 0 || strncasecmp(&file->d_name[strlen(file->d_name) - extensionLen], finddata->extension, extensionLen) == 0)) { sprintf(relativepath, "%s/%s", finddata->folder, file->d_name); realpath(relativepath, path); |