public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Li Huajing <huajing.li@intel.com>
Subject: [PATCH 1/2] Nt32Pkg/WinNtSimpleFileSystemDxe: Change GetInfo() to get TimeZone.
Date: Tue, 25 Jul 2017 18:00:28 +0800	[thread overview]
Message-ID: <20170725100029.31284-2-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20170725100029.31284-1-ruiyu.ni@intel.com>

From: Li Huajing <huajing.li@intel.com>

Signed-off-by: Huajing Li <huajing.li@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 .../WinNtSimpleFileSystem.c                        | 78 +++++++++-------------
 1 file changed, 32 insertions(+), 46 deletions(-)

diff --git a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c
index b687e9c957..f598c8e546 100644
--- a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c
+++ b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c
@@ -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;
-- 
2.12.2.windows.2



  reply	other threads:[~2017-07-25  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 10:00 [PATCH 0/2] Change Shell command ls to display file time in local time Ruiyu Ni
2017-07-25 10:00 ` Ruiyu Ni [this message]
2017-07-25 10:00 ` [PATCH 2/2] ShellPkg/ls: Display the " Ruiyu Ni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170725100029.31284-2-ruiyu.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox