diff options
author | Kostas Nakos | 2008-07-20 11:15:29 +0000 |
---|---|---|
committer | Kostas Nakos | 2008-07-20 11:15:29 +0000 |
commit | 8b5e175af45fc0ff3f5cccc29dc4c522516ab2b6 (patch) | |
tree | 14d1135d93873477d7ee04eb99c9131c9e1bc151 | |
parent | 8c807529a7561bbff96b4a7dfecd06102e2a5f43 (diff) | |
download | scummvm-rg350-8b5e175af45fc0ff3f5cccc29dc4c522516ab2b6.tar.gz scummvm-rg350-8b5e175af45fc0ff3f5cccc29dc4c522516ab2b6.tar.bz2 scummvm-rg350-8b5e175af45fc0ff3f5cccc29dc4c522516ab2b6.zip |
workaround for bogus findfirstfile. kyra now starts up correctly
svn-id: r33120
-rw-r--r-- | backends/platform/wince/missing/missing.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/backends/platform/wince/missing/missing.cpp b/backends/platform/wince/missing/missing.cpp index 86d93dcb88..8574e93f92 100644 --- a/backends/platform/wince/missing/missing.cpp +++ b/backends/platform/wince/missing/missing.cpp @@ -74,6 +74,7 @@ int stat(const char *fname, struct stat *ss) MultiByteToWideChar(CP_ACP, 0, fname, -1, fnameUnc, MAX_PATH); handle = FindFirstFile(fnameUnc, &wfd); + FindClose(handle); if (handle == INVALID_HANDLE_VALUE) return -1; else @@ -83,8 +84,6 @@ int stat(const char *fname, struct stat *ss) ss->st_size = wfd.nFileSizeLow; if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ss->st_mode |= S_IFDIR; - - FindClose(handle); } return 0; } @@ -158,14 +157,22 @@ int _access(const char *path, int mode) { WIN32_FIND_DATA ffd; HANDLE h=FindFirstFile(fname, &ffd); + FindClose(h); if (h == INVALID_HANDLE_VALUE) return -1; //Can't find file - FindClose(h); - if (ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) - return 0; //Always return success if target is directory and exists + if (ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) { + // WORKAROUND: WinCE (or the emulator) sometimes returns bogus direcotry + // hits for files that don't exist. Checking for the same fname twice + // seems to weed out those false positives. + HANDLE h=FindFirstFile(fname, &ffd); + FindClose(h); + if (h == INVALID_HANDLE_VALUE) + return -1; //Can't find file + return 0; //Always return success if target is directory and exists + } switch (mode) { case 00: //Check existence return 0; |