[NTOSKRNL]
authorPierre Schweitzer <pierre@reactos.org>
Mon, 22 Apr 2013 19:36:33 +0000 (19:36 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Mon, 22 Apr 2013 19:36:33 +0000 (19:36 +0000)
Properly handle (as Windows does) WC in case last dot was eaten in path name translation
Fixes last FindFile failing tests

svn path=/trunk/; revision=58833

reactos/dll/win32/kernel32/client/file/find.c

index f8f7562..c73fb29 100644 (file)
@@ -669,7 +669,7 @@ FindFirstFileExW(IN LPCWSTR lpFileName,
         PFIND_DATA_HANDLE FindDataHandle;
         PFIND_FILE_DATA FindFileData;
 
-        UNICODE_STRING NtPath, FilePattern;
+        UNICODE_STRING NtPath, FilePattern, FileName;
         PWSTR NtPathBuffer;
         RTL_RELATIVE_NAME_U RelativePath;
         ULONG DeviceNameInfo = 0;
@@ -679,6 +679,8 @@ FindFirstFileExW(IN LPCWSTR lpFileName,
         IO_STATUS_BLOCK IoStatusBlock;
         HANDLE hDirectory = NULL;
 
+        BOOLEAN HadADot = FALSE;
+
         /*
          * May represent many FILE_BOTH_DIR_INFORMATION
          * or many FILE_FULL_DIR_INFORMATION structures.
@@ -693,6 +695,12 @@ FindFirstFileExW(IN LPCWSTR lpFileName,
             return INVALID_HANDLE_VALUE;
         }
 
+        RtlInitUnicodeString(&FileName, lpFileName);
+        if (FileName.Length != 0 && FileName.Buffer[FileName.Length / sizeof(WCHAR) - 1] == L'.')
+        {
+            HadADot = TRUE;
+        }
+
         if (!RtlDosPathNameToNtPathName_U(lpFileName,
                                           &NtPath,
                                           (PCWSTR*)&FilePattern.Buffer,
@@ -856,6 +864,15 @@ FindFirstFileExW(IN LPCWSTR lpFileName,
 
                 PatternIndex++;
             }
+
+            /* Handle partial wc if our last dot was eaten */
+            if (HadADot)
+            {
+                if (FilePattern.Buffer[FilePattern.Length / sizeof(WCHAR) - 1] == L'*')
+                {
+                    FilePattern.Buffer[FilePattern.Length / sizeof(WCHAR) - 1] = L'<';
+                }
+            }
         }
 
         Status = NtQueryDirectoryFile(hDirectory,