Matteo Bruni : ntdll: Ignore positive matches in read_directory_stat() for case-insensitive filesystems.

Alexandre Julliard julliard at wine.codeweavers.com
Wed May 20 10:04:11 CDT 2015


Module: wine
Branch: master
Commit: 2f0febe60a9f0b29840fc8d60679a8585b788ad5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2f0febe60a9f0b29840fc8d60679a8585b788ad5

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Tue May 19 23:32:34 2015 +0200

ntdll: Ignore positive matches in read_directory_stat() for case-insensitive filesystems.

It's necessary to return the actual filename with correct casing and a
plain stat doesn't allow that. Make read_directory_stat() return the
result of the stat() call on a case-insensitive filesystem only when the
file is missing.

---

 dlls/ntdll/directory.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 81b5c2e..455fbc6 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -2065,8 +2065,9 @@ static int read_directory_stat( int fd, IO_STATUS_BLOCK *io, void *buffer, ULONG
     int unix_len, ret, used_default;
     char *unix_name;
     struct stat st;
+    BOOL case_sensitive = get_dir_case_sensitivity(".");
 
-    TRACE("trying optimisation for file %s\n", debugstr_us( mask ));
+    TRACE("looking up file %s\n", debugstr_us( mask ));
 
     unix_len = ntdll_wcstoumbs( 0, mask->Buffer, mask->Length / sizeof(WCHAR), NULL, 0, NULL, NULL );
     if (!(unix_name = RtlAllocateHeap( GetProcessHeap(), 0, unix_len + 1)))
@@ -2091,7 +2092,7 @@ static int read_directory_stat( int fd, IO_STATUS_BLOCK *io, void *buffer, ULONG
         }
 
         ret = stat( unix_name, &st );
-        if (!ret)
+        if (case_sensitive && !ret)
         {
             union file_directory_info *info = append_entry( buffer, io, length, unix_name, NULL, NULL, class );
             if (info)
@@ -2101,6 +2102,19 @@ static int read_directory_stat( int fd, IO_STATUS_BLOCK *io, void *buffer, ULONG
             }
             else io->u.Status = STATUS_NO_MORE_FILES;
         }
+        else if (!case_sensitive && ret && (errno == ENOENT || errno == ENOTDIR))
+        {
+            /* If the file does not exist, return that info.
+             * If the file DOES exist, return failure and fallback to the next
+             * read_directory_* function (we need to return the case-preserved
+             * filename stored on the filesystem). */
+            ret = 0;
+            io->u.Status = STATUS_NO_MORE_FILES;
+        }
+        else
+        {
+            ret = -1;
+        }
     }
     else ret = -1;
 




More information about the wine-cvs mailing list