/** @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
IN EFI_FILE_HANDLE FileHandle\r
)\r
{\r
- EFI_GUID FileInfoGuid;\r
EFI_FILE_INFO *pFileInfo;\r
UINTN FileInfoSize;\r
EFI_STATUS Status;\r
//\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
// now get the information\r
//\r
Status = FileHandle->GetInfo(FileHandle, \r
- &FileInfoGuid, \r
+ &gEfiFileInfoGuid, \r
&FileInfoSize, \r
pFileInfo);\r
//\r
IN CONST EFI_FILE_INFO *FileInfo\r
)\r
{\r
- EFI_GUID FileInfoGuid;\r
\r
//\r
// ASSERT if the FileHandle or FileInfo is NULL\r
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
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
){\r
UINTN DestinationStartSize;\r
UINTN NewSize;\r
+ UINTN CopySize;\r
\r
//\r
// ASSERTs\r
// Append all of Source?\r
//\r
if (Count == 0) {\r
- Count = StrLen(Source);\r
+ Count = StrSize(Source);\r
}\r
\r
//\r
//\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
EFI_FILE_INFO *FileInfo;\r
\r
Size = 0;\r
- *FullFileName = NULL;\r
\r
//\r
// Check our parameters\r
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
// 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
}\r
\r
if (EFI_ERROR(Status) && *FullFileName != NULL) {\r
- FreePool(FullFileName);\r
+ FreePool(*FullFileName);\r
}\r
\r
return (Status);\r
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
//\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