]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c
comment repairs.
[mirror_edk2.git] / ShellPkg / Library / BaseFileHandleLib / BaseFileHandleLib.c
index 9136b9c20080b5dca78088beb64fb5ac1f519624..ed068243d6976caa7f72e17762dd07bfb2eccda2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to EFI_FILE_HANDLE functionality.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -46,7 +46,6 @@ FileHandleGetInfo (
   IN EFI_FILE_HANDLE            FileHandle\r
   )\r
 {\r
-  EFI_GUID        FileInfoGuid;\r
   EFI_FILE_INFO   *pFileInfo;\r
   UINTN           FileInfoSize;\r
   EFI_STATUS      Status;\r
@@ -59,11 +58,10 @@ FileHandleGetInfo (
   //\r
   // Get the required size to allocate\r
   //\r
-  FileInfoGuid = gEfiFileInfoGuid;\r
   FileInfoSize = 0;\r
   pFileInfo = NULL;\r
   Status = FileHandle->GetInfo(FileHandle, \r
-                               &FileInfoGuid, \r
+                               &gEfiFileInfoGuid, \r
                                &FileInfoSize, \r
                                pFileInfo);\r
   //\r
@@ -76,7 +74,7 @@ FileHandleGetInfo (
   // now get the information\r
   //\r
   Status = FileHandle->GetInfo(FileHandle, \r
-                               &FileInfoGuid, \r
+                               &gEfiFileInfoGuid, \r
                                &FileInfoSize, \r
                                pFileInfo);\r
   //\r
@@ -114,7 +112,6 @@ FileHandleSetInfo (
   IN CONST EFI_FILE_INFO        *FileInfo\r
   )\r
 {\r
-  EFI_GUID        FileInfoGuid;\r
   \r
   //\r
   // ASSERT if the FileHandle or FileInfo is NULL\r
@@ -122,12 +119,11 @@ FileHandleSetInfo (
   ASSERT (FileHandle != NULL);\r
   ASSERT (FileInfo   != NULL);\r
 \r
-  FileInfoGuid = gEfiFileInfoGuid;\r
   //\r
   // Set the info\r
   //\r
   return (FileHandle->SetInfo(FileHandle, \r
-                              &FileInfoGuid,\r
+                              &gEfiFileInfoGuid,\r
                               (UINTN)FileInfo->Size,\r
                               (EFI_FILE_INFO*)FileInfo));\r
 }  \r
@@ -541,14 +537,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
@@ -668,6 +656,7 @@ StrnCatGrowLeft (
   ){\r
   UINTN DestinationStartSize;\r
   UINTN NewSize;\r
+  UINTN CopySize;\r
 \r
   //\r
   // ASSERTs\r
@@ -697,7 +686,7 @@ StrnCatGrowLeft (
   // Append all of Source?\r
   //\r
   if (Count == 0) {\r
-    Count = StrLen(Source);\r
+    Count = StrSize(Source);\r
   }\r
 \r
   //\r
@@ -705,17 +694,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
-  *Destination = CopyMem(*Destination+StrLen(Source), *Destination, StrSize(*Destination));\r
-  *Destination = CopyMem(*Destination, Source, StrLen(Source));\r
+  CopySize = StrSize(*Destination);\r
+  CopyMem((*Destination)+((Count-2)/sizeof(CHAR16)), *Destination, CopySize);\r
+  CopyMem(*Destination, Source, Count-2);\r
   return (*Destination);\r
 }\r
 \r
@@ -747,7 +737,6 @@ FileHandleGetFileName (
   EFI_FILE_INFO   *FileInfo;\r
 \r
   Size = 0;\r
-  *FullFileName = NULL;\r
 \r
   //\r
   // Check our parameters\r
@@ -756,6 +745,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
@@ -771,10 +762,15 @@ 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
+          if (*FullFileName == NULL) {\r
+            *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
+          }\r
           FreePool(FileInfo);\r
           break;\r
         } else {\r
+          if (*FullFileName == NULL) {\r
+            *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
+          }\r
           *FullFileName = StrnCatGrowLeft(FullFileName, &Size, FileInfo->FileName, 0);\r
           *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
           FreePool(FileInfo);\r
@@ -798,7 +794,7 @@ FileHandleGetFileName (
   }\r
 \r
   if (EFI_ERROR(Status) && *FullFileName != NULL) {\r
-    FreePool(FullFileName);\r
+    FreePool(*FullFileName);\r
   }\r
 \r
   return (Status);\r
@@ -808,8 +804,8 @@ FileHandleGetFileName (
   Function to read a single line (up to but not including the \n) from a file.\r
 \r
   @param[in]      Handle        FileHandle to read from\r
-  @param[in,out] Buffer        pointer to buffer to read into\r
-  @param[in,out] Size          pointer to number of bytes in buffer\r
+  @param[in,out]  Buffer        pointer to buffer to read into\r
+  @param[in,out]  Size          pointer to number of bytes in buffer\r
   @param[in[      Truncate      if TRUE then allows for truncation of the line to fit.\r
                                 if FALSE will reset the position to the begining of the \r
                                 line if the buffer is not large enough.\r
@@ -860,7 +856,7 @@ FileHandleReadLine(
     //\r
     if ((CountSoFar+1)*sizeof(CHAR16) < *Size){\r
       ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;\r
-      ((CHAR16*)Buffer)[CountSoFar+1] = '\0';\r
+      ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;\r
     }\r
   }\r
 \r