fixed operation of GetFirst and GetNext for files...

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8957 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey 2009-07-16 17:24:16 +00:00
parent 5caec787e1
commit d595d4b13a
1 changed files with 10 additions and 17 deletions

View File

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