CVS: winex/files dos_fs.c,1.35,1.36

[email protected] 31 Jul 2007 17:45:09 -0000
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/files dos_fs.c,1.35,1.36Update of /var/lib/cvsd/cvsroot/winex/files
In directory agravaine:/tmp/cvs-serv23389/files

Modified Files:
	dos_fs.c 
Log Message:

- add a couple of optimizations possible on Apple due to filesystem being case-insensitive



Index: dos_fs.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/files/dos_fs.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- dos_fs.c	31 Jul 2007 17:43:41 -0000	1.35
+++ dos_fs.c	31 Jul 2007 17:45:07 -0000	1.36
@@ -653,6 +653,20 @@
     }
     HeapFree (GetProcessHeap (), 0, full_path);
 
+#ifdef __APPLE__
+    /* MacOS has a case-insensitive filesystem. Thus, if the initial stat
+       didn't match, the only valid alternative is that we've been given
+       a dos-style short path. Check if that's the case; if not, return
+       failure without bothering to walk the directory (which can be
+       expensive) */
+    if (!DOSFS_ValidDOSName (name, 1))
+    {
+       WARN ("'%s' not a valid dos name and not found in '%s'\n",
+             name, path);
+       return FALSE;
+    }
+#endif
+
     if (!(dir = DOSFS_OpenDir( path )))
     {
         WARN("(%s,%s): can't open dir: %s\n",
@@ -662,6 +676,9 @@
 
     while ((ret = DOSFS_ReadDir( dir, &long_name, &short_name )))
     {
+       /* Apple's case-insensitive, so this will have been caught by
+          the earlier stat optimization */
+#ifndef __APPLE__
         /* Check against Unix name */
         if (len == strlen(long_name))
         {
@@ -674,6 +691,7 @@
                 if (!FILE_strncasecmp( long_name, name, len )) break;
             }
         }
+#endif
         if (dos_name[0])
         {
             /* Check against hashed DOS name */