]> git.proxmox.com Git - mirror_edk2.git/commitdiff
fixed operation of GetFirst and GetNext for files...
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 Jul 2009 17:24:16 +0000 (17:24 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 Jul 2009 17:24:16 +0000 (17:24 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8957 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c

index 3200385ee58b0e63f23105b66ff8e0e1f0c12abb..808ac74d30b62eb811370a9d43e1ac69a71a9073 100644 (file)
@@ -541,14 +541,6 @@ FileHandleFindNextFile(
   ASSERT (DirHandle != NULL);\r
   ASSERT (Buffer    != NULL);\r
   ASSERT (NoFile    != NULL);\r
-  \r
-  //\r
-  // verify that DirHandle is a directory\r
-  //\r
-  Status = FileHandleIsDirectory(DirHandle);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\r
-  } \r
 \r
   //\r
   // This BufferSize MUST stay equal to the originally allocated one in GetFirstFile\r
@@ -698,7 +690,7 @@ StrnCatGrowLeft (
   // Append all of Source?\r
   //\r
   if (Count == 0) {\r
-    Count = StrLen(Source);\r
+    Count = StrSize(Source);\r
   }\r
 \r
   //\r
@@ -706,18 +698,18 @@ StrnCatGrowLeft (
   //\r
   if (CurrentSize != NULL) {\r
     NewSize = *CurrentSize;\r
-    while (NewSize < (DestinationStartSize + (Count*sizeof(CHAR16)))) {\r
-      NewSize += 2 * Count * sizeof(CHAR16);\r
+    while (NewSize < (DestinationStartSize + Count)) {\r
+      NewSize += 2 * Count;\r
     }\r
     *Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);\r
     *CurrentSize = NewSize;\r
   } else {\r
-    *Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));\r
+    *Destination = AllocateZeroPool(Count+sizeof(CHAR16));\r
   }\r
 \r
   CopySize = StrSize(*Destination);\r
-  *Destination = CopyMem((*Destination)+StrLen(Source), *Destination, CopySize);\r
-  *Destination = CopyMem(*Destination, Source, StrLen(Source));\r
+  *Destination = CopyMem(*Destination+Count-sizeof(CHAR16), *Destination, CopySize);\r
+  *Destination = CopyMem(*Destination, Source, Count);\r
   return (*Destination);\r
 }\r
 \r
@@ -749,7 +741,6 @@ FileHandleGetFileName (
   EFI_FILE_INFO   *FileInfo;\r
 \r
   Size = 0;\r
-  *FullFileName = NULL;\r
 \r
   //\r
   // Check our parameters\r
@@ -758,6 +749,8 @@ FileHandleGetFileName (
     return (EFI_INVALID_PARAMETER);\r
   }\r
 \r
+  *FullFileName = NULL;\r
+\r
   Status = Handle->Open(Handle, &CurrentHandle, L".", EFI_FILE_MODE_READ, 0);\r
   if (!EFI_ERROR(Status)) {\r
     //\r
@@ -773,12 +766,12 @@ FileHandleGetFileName (
         // We got info... do we have a name? if yes preceed the current path with it...\r
         //\r
         if (StrLen (FileInfo->FileName) == 0) {\r
-          *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
+          *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"/", 0);\r
           FreePool(FileInfo);\r
           break;\r
         } else {\r
           *FullFileName = StrnCatGrowLeft(FullFileName, &Size, FileInfo->FileName, 0);\r
-          *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
+          *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"/", 0);\r
           FreePool(FileInfo);\r
         }\r
       }\r