[Scummvm-cvs-logs] SF.net SVN: scummvm:[33120] scummvm/trunk/backends/platform/wince/missing/ missing.cpp

knakos at users.sourceforge.net knakos at users.sourceforge.net
Sun Jul 20 13:15:42 CEST 2008


Revision: 33120
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33120&view=rev
Author:   knakos
Date:     2008-07-20 11:15:29 +0000 (Sun, 20 Jul 2008)

Log Message:
-----------
workaround for bogus findfirstfile. kyra now starts up correctly

Modified Paths:
--------------
    scummvm/trunk/backends/platform/wince/missing/missing.cpp

Modified: scummvm/trunk/backends/platform/wince/missing/missing.cpp
===================================================================
--- scummvm/trunk/backends/platform/wince/missing/missing.cpp	2008-07-20 10:02:13 UTC (rev 33119)
+++ scummvm/trunk/backends/platform/wince/missing/missing.cpp	2008-07-20 11:15:29 UTC (rev 33120)
@@ -74,6 +74,7 @@
 
 	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 @@
 		ss->st_size = wfd.nFileSizeLow;
 		if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
 			ss->st_mode |= S_IFDIR;
-
-		FindClose(handle);
 	}
 	return 0;
 }
@@ -158,14 +157,22 @@
 
 	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)
+	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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list