Provide rename compatibility layer
This commit is contained in:
parent
83417b2d6a
commit
b53723bf38
|
@ -782,7 +782,7 @@ int automapSaveCurrent()
|
||||||
// NOTE: Not sure about the size.
|
// NOTE: Not sure about the size.
|
||||||
char automapTmpPath[512];
|
char automapTmpPath[512];
|
||||||
sprintf(automapTmpPath, "%s\\%s\\%s", masterPatchesPath, "MAPS", AUTOMAP_TMP);
|
sprintf(automapTmpPath, "%s\\%s\\%s", masterPatchesPath, "MAPS", AUTOMAP_TMP);
|
||||||
if (rename(automapTmpPath, automapDbPath) != 0) {
|
if (compat_rename(automapTmpPath, automapDbPath) != 0) {
|
||||||
debugPrint("\nAUTOMAP: Error renaming database!\n");
|
debugPrint("\nAUTOMAP: Error renaming database!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2498,7 +2498,7 @@ int _SaveBackup()
|
||||||
File* stream1 = fileOpen(_str0, "rb");
|
File* stream1 = fileOpen(_str0, "rb");
|
||||||
if (stream1 != NULL) {
|
if (stream1 != NULL) {
|
||||||
fileClose(stream1);
|
fileClose(stream1);
|
||||||
if (rename(_str0, _str1) != 0) {
|
if (compat_rename(_str0, _str1) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2520,7 +2520,7 @@ int _SaveBackup()
|
||||||
strcat(_str0, fileList[index]);
|
strcat(_str0, fileList[index]);
|
||||||
|
|
||||||
_strmfe(_str1, _str0, "BAK");
|
_strmfe(_str1, _str0, "BAK");
|
||||||
if (rename(_str0, _str1) != 0) {
|
if (compat_rename(_str0, _str1) != 0) {
|
||||||
fileNameListFree(&fileList, 0);
|
fileNameListFree(&fileList, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2567,7 +2567,7 @@ int _RestoreSave()
|
||||||
_strmfe(_str1, _str0, "BAK");
|
_strmfe(_str1, _str0, "BAK");
|
||||||
compat_remove(_str0);
|
compat_remove(_str0);
|
||||||
|
|
||||||
if (rename(_str1, _str0) != 0) {
|
if (compat_rename(_str1, _str0) != 0) {
|
||||||
_EraseSave();
|
_EraseSave();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2594,7 +2594,7 @@ int _RestoreSave()
|
||||||
strcat(_str0, fileList[index]);
|
strcat(_str0, fileList[index]);
|
||||||
_strmfe(_str1, _str0, "SAV");
|
_strmfe(_str1, _str0, "SAV");
|
||||||
compat_remove(_str1);
|
compat_remove(_str1);
|
||||||
if (rename(_str0, _str1) != 0) {
|
if (compat_rename(_str0, _str1) != 0) {
|
||||||
// FIXME: Probably leaks fileList.
|
// FIXME: Probably leaks fileList.
|
||||||
_EraseSave();
|
_EraseSave();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2616,7 +2616,7 @@ int _RestoreSave()
|
||||||
strcpy(_str1, _gmpath);
|
strcpy(_str1, _gmpath);
|
||||||
strcat(_str1, v2);
|
strcat(_str1, v2);
|
||||||
|
|
||||||
if (rename(_str0, _str1) != 0) {
|
if (compat_rename(_str0, _str1) != 0) {
|
||||||
_EraseSave();
|
_EraseSave();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,6 +179,19 @@ int compat_remove(const char* path)
|
||||||
return remove(nativePath);
|
return remove(nativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int compat_rename(const char* oldFileName, const char* newFileName)
|
||||||
|
{
|
||||||
|
char nativeOldFileName[COMPAT_MAX_PATH];
|
||||||
|
strcpy(nativeOldFileName, oldFileName);
|
||||||
|
compat_windows_path_to_native(nativeOldFileName);
|
||||||
|
|
||||||
|
char nativeNewFileName[COMPAT_MAX_PATH];
|
||||||
|
strcpy(nativeNewFileName, newFileName);
|
||||||
|
compat_windows_path_to_native(nativeNewFileName);
|
||||||
|
|
||||||
|
return rename(nativeOldFileName, nativeNewFileName);
|
||||||
|
}
|
||||||
|
|
||||||
void compat_windows_path_to_native(char* path)
|
void compat_windows_path_to_native(char* path)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
|
@ -37,6 +37,7 @@ unsigned int compat_timeGetTime();
|
||||||
FILE* compat_fopen(const char* path, const char* mode);
|
FILE* compat_fopen(const char* path, const char* mode);
|
||||||
gzFile compat_gzopen(const char* path, const char* mode);
|
gzFile compat_gzopen(const char* path, const char* mode);
|
||||||
int compat_remove(const char* path);
|
int compat_remove(const char* path);
|
||||||
|
int compat_rename(const char* oldFileName, const char* newFileName);
|
||||||
void compat_windows_path_to_native(char* path);
|
void compat_windows_path_to_native(char* path);
|
||||||
|
|
||||||
#endif /* PLATFORM_COMPAT_H */
|
#endif /* PLATFORM_COMPAT_H */
|
||||||
|
|
Loading…
Reference in New Issue