summaryrefslogtreecommitdiffstats
path: root/src/skel
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-07-12 03:13:22 +0200
committerSergeanur <s.anureev@yandex.ua>2021-07-12 03:13:22 +0200
commit55d30a11ec04200091db0e29a44ceec6522fedfb (patch)
treeb8a5bdbd323615ae8ea250174e8f22b7e9ab5f18 /src/skel
parentMerge remote-tracking branch 'origin/miami' into lcs (diff)
parentReorganize config.h (diff)
downloadre3-55d30a11ec04200091db0e29a44ceec6522fedfb.tar
re3-55d30a11ec04200091db0e29a44ceec6522fedfb.tar.gz
re3-55d30a11ec04200091db0e29a44ceec6522fedfb.tar.bz2
re3-55d30a11ec04200091db0e29a44ceec6522fedfb.tar.lz
re3-55d30a11ec04200091db0e29a44ceec6522fedfb.tar.xz
re3-55d30a11ec04200091db0e29a44ceec6522fedfb.tar.zst
re3-55d30a11ec04200091db0e29a44ceec6522fedfb.zip
Diffstat (limited to 'src/skel')
-rw-r--r--src/skel/crossplatform.cpp23
-rw-r--r--src/skel/crossplatform.h3
2 files changed, 26 insertions, 0 deletions
diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp
index 68df6704..f7016b21 100644
--- a/src/skel/crossplatform.cpp
+++ b/src/skel/crossplatform.cpp
@@ -155,6 +155,29 @@ FILE* _fcaseopen(char const* filename, char const* mode)
return result;
}
+int _caserename(const char *old_filename, const char *new_filename)
+{
+ int result;
+ char *real_old = casepath(old_filename);
+ char *real_new = casepath(new_filename);
+
+ // hack so we don't even try to rename it to new_filename if it already exists
+ if (!real_new) {
+ free(real_old);
+ return -1;
+ }
+
+ if (!real_old)
+ result = rename(old_filename, real_new);
+ else
+ result = rename(real_old, real_new);
+
+ free(real_old);
+ free(real_new);
+
+ return result;
+}
+
// Case-insensitivity on linux (from https://github.com/OneSadCookie/fcaseopen)
// Returned string should freed manually (if exists)
char* casepath(char const* path, bool checkPathFirst)
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index a073f854..f37e64a1 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -33,6 +33,7 @@ char *_strdate(char *buf);
#endif
extern DWORD _dwOperatingSystemVersion;
#define fcaseopen fopen
+#define caserename rename
#else
char *strupr(char *str);
char *strlwr(char *str);
@@ -55,6 +56,8 @@ extern long _dwOperatingSystemVersion;
char *casepath(char const *path, bool checkPathFirst = true);
FILE *_fcaseopen(char const *filename, char const *mode);
#define fcaseopen _fcaseopen
+int _caserename(const char *old_filename, const char *new_filename);
+#define caserename _caserename
#endif
#ifdef RW_GL3