Mercurial > hg > openttd
changeset 17721:688b683f70b7 draft
(svn r22501) -Codechange: Move FileExists to a better place.
author | alberth <alberth@openttd.org> |
---|---|
date | Fri, 27 May 2011 21:42:51 +0000 (2011-05-27) |
parents | 795ca83b0ab4 |
children | 67faa494ca70 |
files | src/fileio.cpp src/fios.cpp |
diffstat | 2 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -265,6 +265,24 @@ } /** + * 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)
--- a/src/fios.cpp +++ b/src/fios.cpp @@ -186,19 +186,6 @@ 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); /**