mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 15:40:00 +00:00
Cross-platform fix and a little style change
This commit is contained in:
parent
0750f04019
commit
0265804003
|
@ -26,34 +26,39 @@ void GetLocalTime_CP(SYSTEMTIME *out) {
|
||||||
// Compatible with Linux/POSIX and MinGW on Windows
|
// Compatible with Linux/POSIX and MinGW on Windows
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) {
|
HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) {
|
||||||
char newpathname[32];
|
char pathCopy[32];
|
||||||
|
|
||||||
strncpy(newpathname, pathname, 32);
|
strncpy(pathCopy, pathname, 32);
|
||||||
char* path = strtok(newpathname, "*");
|
char* folder = strtok(pathCopy, "*");
|
||||||
|
|
||||||
// Case-sensitivity and backslashes...
|
// Case-sensitivity and backslashes...
|
||||||
char *real = casepath(path);
|
char *realFolder = casepath(folder);
|
||||||
if (real) {
|
char *extension = nil;
|
||||||
real[strlen(real)] = '*';
|
if (realFolder) {
|
||||||
char *extension = strtok(NULL, "*");
|
realFolder[strlen(realFolder)] = '*';
|
||||||
if (extension)
|
extension = strtok(NULL, "*");
|
||||||
strcat(real, extension);
|
if (extension) {
|
||||||
|
strcat(realFolder, extension);
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(newpathname, real, 32);
|
strncpy(pathCopy, realFolder, 32);
|
||||||
free(real);
|
free(realFolder);
|
||||||
path = strtok(newpathname, "*");
|
folder = strtok(pathCopy, "*");
|
||||||
|
} else {
|
||||||
|
// Wildcard (*)
|
||||||
|
if (strlen(folder) + 1 != strlen(pathname))
|
||||||
|
extension = strtok(NULL, "*");
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(firstfile->folder, path, sizeof(firstfile->folder));
|
strncpy(firstfile->folder, folder, sizeof(firstfile->folder));
|
||||||
|
|
||||||
// Both w/ extension and w/o extension is ok
|
if (extension)
|
||||||
if (strlen(path) + 1 != strlen(pathname))
|
strncpy(firstfile->extension, extension, sizeof(firstfile->extension));
|
||||||
strncpy(firstfile->extension, strtok(NULL, "*"), sizeof(firstfile->extension));
|
|
||||||
else
|
else
|
||||||
strncpy(firstfile->extension, "", sizeof(firstfile->extension));
|
firstfile->extension[0] = '\0';
|
||||||
|
|
||||||
HANDLE d;
|
HANDLE d;
|
||||||
if ((d = (HANDLE)opendir(path)) == NULL || !FindNextFile(d, firstfile))
|
if ((d = (HANDLE)opendir(folder)) == NULL || !FindNextFile(d, firstfile))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
|
|
@ -71,10 +71,7 @@ CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size)
|
||||||
if (len1 != len2 && (len1 < size || len2 < size))
|
if (len1 != len2 && (len1 < size || len2 < size))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int32 i = 0; i < size; i++) {
|
for (int32 i = 0; FixupChar(str1[i]) != '\0' && i < size; i++) {
|
||||||
if (FixupChar(str1[i]) == '\0' || i > size)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (FixupChar(str1[i]) != FixupChar(str2[i]))
|
if (FixupChar(str1[i]) != FixupChar(str2[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -393,7 +390,7 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32
|
||||||
if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') {
|
if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') {
|
||||||
#endif
|
#endif
|
||||||
c += 3;
|
c += 3;
|
||||||
for (int j=0; j<outLen; j++)
|
for (int j = 0; j < outLen; j++)
|
||||||
*(outstr++) = wNumStr[j++];
|
*(outstr++) = wNumStr[j++];
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
Loading…
Reference in a new issue