summaryrefslogtreecommitdiffstats
path: root/src/fakerw/fake.cpp
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2020-05-11 04:55:57 +0200
committereray orçunus <erayorcunus@gmail.com>2020-05-11 20:00:55 +0200
commit8a4fa58cd42b7cca4a86fe2d9913b839b554bf10 (patch)
tree294e44de2168e1b581ba847775d827924c07bf2e /src/fakerw/fake.cpp
parentMerge pull request #509 from Fire-Head/master (diff)
downloadre3-8a4fa58cd42b7cca4a86fe2d9913b839b554bf10.tar
re3-8a4fa58cd42b7cca4a86fe2d9913b839b554bf10.tar.gz
re3-8a4fa58cd42b7cca4a86fe2d9913b839b554bf10.tar.bz2
re3-8a4fa58cd42b7cca4a86fe2d9913b839b554bf10.tar.lz
re3-8a4fa58cd42b7cca4a86fe2d9913b839b554bf10.tar.xz
re3-8a4fa58cd42b7cca4a86fe2d9913b839b554bf10.tar.zst
re3-8a4fa58cd42b7cca4a86fe2d9913b839b554bf10.zip
Diffstat (limited to 'src/fakerw/fake.cpp')
-rw-r--r--src/fakerw/fake.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp
index f1531490..50d12b2f 100644
--- a/src/fakerw/fake.cpp
+++ b/src/fakerw/fake.cpp
@@ -7,6 +7,9 @@
#include <rpskin.h>
#include <assert.h>
#include <string.h>
+#ifndef _WIN32
+#include "crossplatform.h"
+#endif
using namespace rw;
@@ -371,8 +374,24 @@ RwStream *RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, const v
StreamFile fakefile;
file = rwNewT(StreamFile, 1, 0);
memcpy(file, &fakefile, sizeof(StreamFile));
+#ifndef _WIN32
+ // Be case-insensitive and fix backslashes (from https://github.com/OneSadCookie/fcaseopen/)
+ FILE* first = fopen((char*)pData, "r");
+ char *r;
+ if (!first) {
+ r = (char*)alloca(strlen((char*)pData) + 2);
+ // Use default path(and pass error handling to librw) if we can't find any match
+ if (!casepath((char*)pData, r))
+ r = (char*)pData;
+ } else
+ fclose(first);
+
+ if(file->open((char*)r, mode))
+ return file;
+#else
if(file->open((char*)pData, mode))
return file;
+#endif
rwFree(file);
return nil;
}