mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-12 01:24:54 +00:00
(svn r22501) -Codechange: Move FileExists to a better place.
This commit is contained in:
parent
f5637b7975
commit
6e3ef9fa1a
@ -264,6 +264,24 @@ bool FioCheckFileExists(const char *filename, Subdirectory subdir)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
13
src/fios.cpp
13
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);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user