summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2011-05-27 21:42:51 +0000
committeralberth <alberth@openttd.org>2011-05-27 21:42:51 +0000
commit6e3ef9fa1a6705e91467678ce615c630ee4d343d (patch)
tree3c586d109df743e4de048cd6e3a853954403bf3a
parentf5637b797540120201d98a23f7bb607550fda21b (diff)
downloadopenttd-6e3ef9fa1a6705e91467678ce615c630ee4d343d.tar.xz
(svn r22501) -Codechange: Move FileExists to a better place.
-rw-r--r--src/fileio.cpp18
-rw-r--r--src/fios.cpp13
2 files changed, 18 insertions, 13 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 78e946d23..5ddce0570 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -265,6 +265,24 @@ bool FioCheckFileExists(const char *filename, Subdirectory subdir)
}
/**
+ * Test whether the fiven filename exists.
+ * @param filename the file to test.
+ * @return true if and only if the file exists.
+ */
+bool FileExists(const char *filename)
+{
+#if defined(WINCE)
+ /* There is always one platform that doesn't support basic commands... */
+ HANDLE hand = CreateFile(OTTD2FS(filename), 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+ if (hand == INVALID_HANDLE_VALUE) return 1;
+ CloseHandle(hand);
+ return 0;
+#else
+ return access(OTTD2FS(filename), 0) == 0;
+#endif
+}
+
+/**
* Close a file in a safe way.
*/
void FioFCloseFile(FILE *f)
diff --git a/src/fios.cpp b/src/fios.cpp
index 37b530cbd..2856c0c5a 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -186,19 +186,6 @@ bool FiosDelete(const char *name)
return unlink(filename) == 0;
}
-bool FileExists(const char *filename)
-{
-#if defined(WINCE)
- /* There is always one platform that doesn't support basic commands... */
- HANDLE hand = CreateFile(OTTD2FS(filename), 0, 0, NULL, OPEN_EXISTING, 0, NULL);
- if (hand == INVALID_HANDLE_VALUE) return 1;
- CloseHandle(hand);
- return 0;
-#else
- return access(OTTD2FS(filename), 0) == 0;
-#endif
-}
-
typedef FiosType fios_getlist_callback_proc(SaveLoadDialogMode mode, const char *filename, const char *ext, char *title, const char *last);
/**