Nt32Pkg/WinNtSimpleFileSystemDxe: Change GetInfo() to get TimeZone.

Signed-off-by: Huajing Li <huajing.li@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
This commit is contained in:
Li Huajing 2017-07-24 15:31:42 +08:00 committed by Ruiyu Ni
parent 688c7d21b9
commit c46aeceaf6
1 changed files with 32 additions and 46 deletions

View File

@ -1492,6 +1492,30 @@ Returns:
}
}
/**
Convert the FileTime to EfiTime.
@param PrivateFile Pointer to WIN_NT_EFI_FILE_PRIVATE.
@param TimeZone Pointer to the current time zone.
@param FileTime Pointer to file time.
@param EfiTime Pointer to EFI time.
**/
VOID
WinNtFileTimeToEfiTime (
IN CONST WIN_NT_EFI_FILE_PRIVATE *PrivateFile,
IN TIME_ZONE_INFORMATION *TimeZone,
IN CONST FILETIME *FileTime,
OUT EFI_TIME *EfiTime
)
{
FILETIME TempFileTime;
SYSTEMTIME SystemTime;
PrivateFile->WinNtThunk->FileTimeToLocalFileTime (FileTime, &TempFileTime);
PrivateFile->WinNtThunk->FileTimeToSystemTime (&TempFileTime, &SystemTime);
WinNtSystemTimeToEfiTime (&SystemTime, TimeZone, EfiTime);
}
EFI_STATUS
EFIAPI
WinNtSimpleFileSystemRead (
@ -1535,7 +1559,6 @@ Returns:
UINTN NameSize;
UINTN ResultSize;
UINTN Index;
SYSTEMTIME SystemTime;
EFI_FILE_INFO *Info;
WCHAR *pw;
TIME_ZONE_INFORMATION TimeZone;
@ -1642,24 +1665,9 @@ Returns:
Info->Size = ResultSize;
PrivateFile->WinNtThunk->GetTimeZoneInformation (&TimeZone);
PrivateFile->WinNtThunk->FileTimeToLocalFileTime (
&PrivateFile->FindBuf.ftCreationTime,
&PrivateFile->FindBuf.ftCreationTime
);
PrivateFile->WinNtThunk->FileTimeToSystemTime (&PrivateFile->FindBuf.ftCreationTime, &SystemTime);
WinNtSystemTimeToEfiTime (&SystemTime, &TimeZone, &Info->CreateTime);
PrivateFile->WinNtThunk->FileTimeToLocalFileTime (
&PrivateFile->FindBuf.ftLastWriteTime,
&PrivateFile->FindBuf.ftLastWriteTime
);
PrivateFile->WinNtThunk->FileTimeToSystemTime (&PrivateFile->FindBuf.ftLastWriteTime, &SystemTime);
WinNtSystemTimeToEfiTime (&SystemTime, &TimeZone, &Info->ModificationTime);
WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &PrivateFile->FindBuf.ftCreationTime, &Info->CreateTime);
WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &PrivateFile->FindBuf.ftLastAccessTime, &Info->LastAccessTime);
WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &PrivateFile->FindBuf.ftLastWriteTime, &Info->ModificationTime);
Info->FileSize = PrivateFile->FindBuf.nFileSizeLow;
@ -1988,9 +1996,9 @@ Returns:
UINTN ResultSize;
EFI_FILE_INFO *Info;
BY_HANDLE_FILE_INFORMATION FileInfo;
SYSTEMTIME SystemTime;
CHAR16 *RealFileName;
CHAR16 *TempPointer;
TIME_ZONE_INFORMATION TimeZone;
Size = SIZE_OF_EFI_FILE_INFO;
@ -2022,32 +2030,10 @@ Returns:
Info->FileSize = FileInfo.nFileSizeLow;
Info->PhysicalSize = Info->FileSize;
PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftCreationTime, &FileInfo.ftCreationTime);
PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftCreationTime, &SystemTime);
Info->CreateTime.Year = SystemTime.wYear;
Info->CreateTime.Month = (UINT8) SystemTime.wMonth;
Info->CreateTime.Day = (UINT8) SystemTime.wDay;
Info->CreateTime.Hour = (UINT8) SystemTime.wHour;
Info->CreateTime.Minute = (UINT8) SystemTime.wMinute;
Info->CreateTime.Second = (UINT8) SystemTime.wSecond;
PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftLastAccessTime, &FileInfo.ftLastAccessTime);
PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftLastAccessTime, &SystemTime);
Info->LastAccessTime.Year = SystemTime.wYear;
Info->LastAccessTime.Month = (UINT8) SystemTime.wMonth;
Info->LastAccessTime.Day = (UINT8) SystemTime.wDay;
Info->LastAccessTime.Hour = (UINT8) SystemTime.wHour;
Info->LastAccessTime.Minute = (UINT8) SystemTime.wMinute;
Info->LastAccessTime.Second = (UINT8) SystemTime.wSecond;
PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftLastWriteTime, &FileInfo.ftLastWriteTime);
PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftLastWriteTime, &SystemTime);
Info->ModificationTime.Year = SystemTime.wYear;
Info->ModificationTime.Month = (UINT8) SystemTime.wMonth;
Info->ModificationTime.Day = (UINT8) SystemTime.wDay;
Info->ModificationTime.Hour = (UINT8) SystemTime.wHour;
Info->ModificationTime.Minute = (UINT8) SystemTime.wMinute;
Info->ModificationTime.Second = (UINT8) SystemTime.wSecond;
PrivateFile->WinNtThunk->GetTimeZoneInformation (&TimeZone);
WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &FileInfo.ftCreationTime, &Info->CreateTime);
WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &FileInfo.ftLastAccessTime, &Info->LastAccessTime);
WinNtFileTimeToEfiTime (PrivateFile, &TimeZone, &FileInfo.ftLastWriteTime, &Info->ModificationTime);
if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) {
Info->Attribute |= EFI_FILE_ARCHIVE;