- Use FsRtl routines for wildcard handling.
authorFilip Navara <filip.navara@gmail.com>
Tue, 31 Aug 2004 16:08:38 +0000 (16:08 +0000)
committerFilip Navara <filip.navara@gmail.com>
Tue, 31 Aug 2004 16:08:38 +0000 (16:08 +0000)
svn path=/trunk/; revision=10753

reactos/drivers/fs/vfat/create.c
reactos/drivers/fs/vfat/string.c

index 6d59895..a3d2858 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: create.c,v 1.73 2004/08/28 22:19:12 navaraf Exp $
+/* $Id: create.c,v 1.74 2004/08/31 16:08:37 navaraf Exp $
  *
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/fs/vfat/create.c
@@ -177,11 +177,9 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
   PVOID Context = NULL;
   PVOID Page;
   PVFATFCB rcFcb;
-  BOOLEAN FoundLong;
-  BOOLEAN FoundShort = FALSE;
+  BOOLEAN Found;
   UNICODE_STRING PathNameU;
   BOOLEAN WildCard;
-  PWCHAR curr, last;
 
   DPRINT ("FindFile(Parent %x, FileToFind '%wZ', DirIndex: %d)\n", 
           Parent, FileToFindU, DirContext->DirIndex);
@@ -194,19 +192,7 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
   DirContext->LongNameU.Length = 0;
   DirContext->ShortNameU.Length = 0;
 
-  /* FIXME: Use FsRtlDoesNameContainWildCards */
-  WildCard = FALSE;
-  curr = FileToFindU->Buffer;
-  last = FileToFindU->Buffer + FileToFindU->Length / sizeof(WCHAR);
-  while (curr < last)
-    {
-      if (*curr == L'?' || *curr == L'*')
-        {
-         WildCard = TRUE;
-         break;
-       }
-      curr++;
-    }
+  WildCard = FsRtlDoesNameContainWildCards(FileToFindU);
 
   if (WildCard == FALSE)
     {
@@ -256,40 +242,19 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
           DirContext->DirIndex++;
           continue;
         }
-      DirContext->LongNameU.Buffer[DirContext->LongNameU.Length / sizeof(WCHAR)] = 0;
-      DirContext->ShortNameU.Buffer[DirContext->ShortNameU.Length / sizeof(WCHAR)] = 0;
       if (WildCard)
         {
-         /* FIXME: Use FsRtlIsNameInExpression */
-          if (DirContext->LongNameU.Length > 0 && 
-             wstrcmpjoki (DirContext->LongNameU.Buffer, FileToFindU->Buffer))
-            {
-             FoundLong = TRUE;
-           }
-          else
-            {
-             FoundLong = FALSE;
-           }
-          if (FoundLong == FALSE)
-            {
-             /* FIXME: Use FsRtlIsNameInExpression */
-             FoundShort = wstrcmpjoki (DirContext->ShortNameU.Buffer, FileToFindU->Buffer);
-           }
-          else
-            {
-             FoundShort = FALSE;
-           }
+          Found = FsRtlIsNameInExpression(FileToFindU, &DirContext->LongNameU, TRUE, NULL) ||
+                  FsRtlIsNameInExpression(FileToFindU, &DirContext->ShortNameU, TRUE, NULL);
        }
       else
         {
-         FoundLong = RtlEqualUnicodeString(&DirContext->LongNameU, FileToFindU, TRUE);
-         if (FoundLong == FALSE)
-           {
-             FoundShort = RtlEqualUnicodeString(&DirContext->ShortNameU, FileToFindU, TRUE);
-           }
+          /* FIXME: Use FsRtlAreNamesEqual */
+          Found = RtlEqualUnicodeString(&DirContext->LongNameU, FileToFindU, TRUE) ||
+                 RtlEqualUnicodeString(&DirContext->ShortNameU, FileToFindU, TRUE);
        }
 
-      if (FoundLong || FoundShort)
+      if (Found)
         {
          if (WildCard)
            {
index 398068a..29ad8ee 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: string.c,v 1.12 2003/10/11 17:51:56 hbirr Exp $
+/* $Id: string.c,v 1.13 2004/08/31 16:08:38 navaraf Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -28,40 +28,3 @@ vfatIsLongIllegal(WCHAR c)
 {
   return wcschr(long_illegals, c) ? TRUE : FALSE;
 }
-
-BOOLEAN wstrcmpjoki(PWSTR s1, PWSTR s2)
-/*
- * FUNCTION: Compare two wide character strings, s2 with jokers (* or ?)
- * return TRUE if s1 like s2
- */
-{
-   while ((*s2==L'*')||(*s2==L'?')||(RtlUpcaseUnicodeChar(*s1)==RtlUpcaseUnicodeChar(*s2)))
-   {
-      if ((*s1)==0 && (*s2)==0)
-        return(TRUE);
-      if(*s2=='*')
-      {
-       s2++;
-        while (*s1)
-        if (wstrcmpjoki(s1,s2)) return TRUE;
-         else s1++;
-      }
-      else
-      {
-        s1++;
-        s2++;
-      }
-   }
-   if ((*s2)==L'.')
-   {
-       for (;((*s2)==L'.')||((*s2)==L'*')||((*s2)==L'?');s2++) {}
-   }
-   if ((*s1)==0 && (*s2)==0)
-        return(TRUE);
-   return(FALSE);
-}
-
-
-
-
-