summaryrefslogtreecommitdiff
path: root/fileio.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-07-31 22:24:09 +0000
committerDarkvater <Darkvater@openttd.org>2006-07-31 22:24:09 +0000
commitba77f85bed8d46c9eef9ed26322d9de5aa321372 (patch)
tree58985e2133fb23e5fdb3a250a34cf54d6362f29a /fileio.c
parent3797cf803802b4c026f90306ecd379f1e2a17298 (diff)
downloadopenttd-ba77f85bed8d46c9eef9ed26322d9de5aa321372.tar.xz
(svn r5686) - Codechange: Use only FioFOpenFile for opening files, use the other similar functions (FioCheckFileExists and FioOpenFile) as its caller.
Diffstat (limited to 'fileio.c')
-rw-r--r--fileio.c60
1 files changed, 6 insertions, 54 deletions
diff --git a/fileio.c b/fileio.c
index 704b64330..3925d7566 100644
--- a/fileio.c
+++ b/fileio.c
@@ -105,34 +105,11 @@ void FioCloseAll(void)
bool FioCheckFileExists(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) { // Make lower case and try again
- strtolower(buf + strlen(_path.data_dir) - 1);
- 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);
- strtolower(buf + strlen(_path.second_data_dir) - 1);
- f = fopen(buf, "rb");
- }
-#endif
- }
-#endif
+ FILE *f = FioFOpenFile(filename);
+ if (f == NULL) return false;
- if (f == NULL) {
- return false;
- } else {
- fclose(f);
- return true;
- }
+ fclose(f);
+ return true;
}
FILE *FioFOpenFile(const char *filename)
@@ -164,34 +141,9 @@ FILE *FioFOpenFile(const char *filename)
void FioOpenFile(int slot, 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) {
- strtolower(buf + strlen(_path.data_dir) - 1);
- 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);
- strtolower(buf + strlen(_path.second_data_dir) - 1);
- f = fopen(buf, "rb");
- }
-
- if (f == NULL)
- sprintf(buf, "%s%s", _path.data_dir, filename); //makes it print the primary datadir path instead of the secundary one
-
-#endif
- }
-#endif
+ FILE *f = FioFOpenFile(filename);
- if (f == NULL)
- error("Cannot open file '%s'", buf);
+ if (f == NULL) error("Cannot open file '%s%s'", _path.data_dir, filename);
FioCloseFile(slot); // if file was opened before, close it
_fio.handles[slot] = f;