[NTFS] Optimize directory search initialization
authorHervé Poussineau <hpoussin@reactos.org>
Sun, 2 Nov 2014 20:18:27 +0000 (20:18 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Sun, 2 Nov 2014 20:18:27 +0000 (20:18 +0000)
svn path=/trunk/; revision=65195

reactos/drivers/filesystems/ntfs/dirctl.c

index ca9ea19..6a207e1 100644 (file)
@@ -305,7 +305,6 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
     PNTFS_FCB Fcb;
     PNTFS_CCB Ccb;
     BOOLEAN First = FALSE;
-    BOOLEAN WildCard;
     PIO_STACK_LOCATION Stack;
     PFILE_OBJECT FileObject;
     NTSTATUS Status = STATUS_SUCCESS;
@@ -338,16 +337,23 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
         if (!Ccb->DirectorySearchPattern)
         {
             First = TRUE;
-            Ccb->DirectorySearchPattern =
-                ExAllocatePoolWithTag(NonPagedPool, SearchPattern->Length + sizeof(WCHAR), TAG_NTFS);
+            Pattern.Length = 0;
+            Pattern.MaximumLength = SearchPattern->Length + sizeof(WCHAR);
+            Ccb->DirectorySearchPattern = Pattern.Buffer =
+                ExAllocatePoolWithTag(NonPagedPool, Pattern.MaximumLength, TAG_NTFS);
             if (!Ccb->DirectorySearchPattern)
             {
                 return STATUS_INSUFFICIENT_RESOURCES;
             }
 
-            memcpy(Ccb->DirectorySearchPattern,
-                   SearchPattern->Buffer,
-                   SearchPattern->Length);
+            Status = RtlUpcaseUnicodeString(&Pattern, SearchPattern, FALSE);
+            if (!NT_SUCCESS(Status))
+            {
+                DPRINT1("RtlUpcaseUnicodeString('%wZ') failed with status 0x%08lx\n", &Pattern, Status);
+                ExFreePoolWithTag(Ccb->DirectorySearchPattern, TAG_NTFS);
+                Ccb->DirectorySearchPattern = NULL;
+                return Status;
+            }
             Ccb->DirectorySearchPattern[SearchPattern->Length / sizeof(WCHAR)] = 0;
         }
     }
@@ -365,19 +371,8 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
     }
 
     RtlInitUnicodeString(&Pattern, Ccb->DirectorySearchPattern);
-    WildCard = FsRtlDoesNameContainWildCards(&Pattern);
-    if (WildCard)
-    {
-        Status = RtlUpcaseUnicodeString(&Pattern, &Pattern, FALSE);
-        if (!NT_SUCCESS(Status))
-        {
-            DPRINT1("RtlUpcaseUnicodeString('%wZ') failed with status 0x%08lx\n", &Pattern, Status);
-            return Status;
-        }
-    }
-
-    DPRINT1("Search pattern '%S'\n", Ccb->DirectorySearchPattern);
-    DPRINT1("In: '%S'\n", Fcb->PathName);
+    DPRINT("Search pattern '%S'\n", Ccb->DirectorySearchPattern);
+    DPRINT("In: '%S'\n", Fcb->PathName);
 
     /* Determine directory index */
     if (Stack->Flags & SL_INDEX_SPECIFIED)