summaryrefslogtreecommitdiff
path: root/fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'fileio.c')
-rw-r--r--fileio.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/fileio.c b/fileio.c
index d8adac9fb..d0013cf1f 100644
--- a/fileio.c
+++ b/fileio.c
@@ -141,6 +141,37 @@ bool FiosCheckFileExists(const char *filename)
}
}
+FILE *FioFOpenFile(const char *filename)
+{
+ FILE *f;
+ char buf[MAX_PATH];
+
+ sprintf(buf, "%s%s", _path.data_dir, filename);
+
+ f = fopen(buf, "rb");
+#if !defined(WIN32)
+ if (f == NULL) {
+ char *s;
+ // Make lower case and try again
+ for(s=buf + strlen(_path.data_dir) - 1; *s != 0; s++)
+ *s = tolower(*s);
+ f = fopen(buf, "rb");
+
+#if defined SECOND_DATA_DIR
+ // tries in the 2nd data directory
+ if (f == NULL) {
+ sprintf(buf, "%s%s", _path.second_data_dir, filename);
+ for(s=buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
+ *s = tolower(*s);
+ f = fopen(buf, "rb");
+ }
+#endif
+ }
+#endif
+
+ return f;
+}
+
void FioOpenFile(int slot, const char *filename)
{
FILE *f;