Author: pschweitzer
Date: Sun Mar 6 13:28:11 2011
New Revision: 50983
URL:
http://svn.reactos.org/svn/reactos?rev=50983&view=rev
Log:
[KERNEL32]
Fixed implementation of both GetFileTime/SetFileTime
Modified:
trunk/reactos/dll/win32/kernel32/file/file.c
Modified: trunk/reactos/dll/win32/kernel32/file/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/fi…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/file/file.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/file/file.c [iso-8859-1] Sun Mar 6 13:28:11 2011
@@ -1421,40 +1421,51 @@
* @implemented
*/
BOOL WINAPI
-GetFileTime(HANDLE hFile,
- LPFILETIME lpCreationTime,
- LPFILETIME lpLastAccessTime,
- LPFILETIME lpLastWriteTime)
-{
- IO_STATUS_BLOCK IoStatusBlock;
- FILE_BASIC_INFORMATION FileBasic;
- NTSTATUS Status;
-
- if(IsConsoleHandle(hFile))
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = NtQueryInformationFile(hFile,
- &IoStatusBlock,
- &FileBasic,
- sizeof(FILE_BASIC_INFORMATION),
- FileBasicInformation);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
-
- if (lpCreationTime)
- memcpy(lpCreationTime, &FileBasic.CreationTime, sizeof(FILETIME));
- if (lpLastAccessTime)
- memcpy(lpLastAccessTime, &FileBasic.LastAccessTime, sizeof(FILETIME));
- if (lpLastWriteTime)
- memcpy(lpLastWriteTime, &FileBasic.LastWriteTime, sizeof(FILETIME));
-
- return TRUE;
+GetFileTime(IN HANDLE hFile,
+ OUT LPFILETIME lpCreationTime OPTIONAL,
+ OUT LPFILETIME lpLastAccessTime OPTIONAL,
+ OUT LPFILETIME lpLastWriteTime OPTIONAL)
+{
+ NTSTATUS Status;
+ IO_STATUS_BLOCK IoStatusBlock;
+ FILE_BASIC_INFORMATION FileBasic;
+
+ if(IsConsoleHandle(hFile))
+ {
+ BaseSetLastNTError(STATUS_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ Status = NtQueryInformationFile(hFile,
+ &IoStatusBlock,
+ &FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ if (lpCreationTime)
+ {
+ lpCreationTime->dwLowDateTime = FileBasic.CreationTime.LowPart;
+ lpCreationTime->dwHighDateTime = FileBasic.CreationTime.HighPart;
+ }
+
+ if (lpLastAccessTime)
+ {
+ lpLastAccessTime->dwLowDateTime = FileBasic.LastAccessTime.LowPart;
+ lpLastAccessTime->dwHighDateTime = FileBasic.LastAccessTime.HighPart;
+ }
+
+ if (lpLastWriteTime)
+ {
+ lpLastWriteTime->dwLowDateTime = FileBasic.LastWriteTime.LowPart;
+ lpLastWriteTime->dwHighDateTime = FileBasic.LastWriteTime.HighPart;
+ }
+
+ return TRUE;
}
@@ -1462,53 +1473,53 @@
* @implemented
*/
BOOL WINAPI
-SetFileTime(HANDLE hFile,
- CONST FILETIME *lpCreationTime,
- CONST FILETIME *lpLastAccessTime,
- CONST FILETIME *lpLastWriteTime)
-{
- FILE_BASIC_INFORMATION FileBasic;
- IO_STATUS_BLOCK IoStatusBlock;
- NTSTATUS Status;
-
- if(IsConsoleHandle(hFile))
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = NtQueryInformationFile(hFile,
- &IoStatusBlock,
- &FileBasic,
- sizeof(FILE_BASIC_INFORMATION),
- FileBasicInformation);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
-
- if (lpCreationTime)
- memcpy(&FileBasic.CreationTime, lpCreationTime, sizeof(FILETIME));
- if (lpLastAccessTime)
- memcpy(&FileBasic.LastAccessTime, lpLastAccessTime, sizeof(FILETIME));
- if (lpLastWriteTime)
- memcpy(&FileBasic.LastWriteTime, lpLastWriteTime, sizeof(FILETIME));
-
- // should i initialize changetime ???
-
- Status = NtSetInformationFile(hFile,
- &IoStatusBlock,
- &FileBasic,
- sizeof(FILE_BASIC_INFORMATION),
- FileBasicInformation);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
-
- return TRUE;
+SetFileTime(IN HANDLE hFile,
+ CONST FILETIME *lpCreationTime OPTIONAL,
+ CONST FILETIME *lpLastAccessTime OPTIONAL,
+ CONST FILETIME *lpLastWriteTime OPTIONAL)
+{
+ NTSTATUS Status;
+ IO_STATUS_BLOCK IoStatusBlock;
+ FILE_BASIC_INFORMATION FileBasic;
+
+ if(IsConsoleHandle(hFile))
+ {
+ BaseSetLastNTError(STATUS_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ memset(&FileBasic, 0, sizeof(FILE_BASIC_INFORMATION));
+
+ if (lpCreationTime)
+ {
+ FileBasic.CreationTime.LowPart = lpCreationTime->dwLowDateTime;
+ FileBasic.CreationTime.HighPart = lpCreationTime->dwHighDateTime;
+ }
+
+ if (lpLastAccessTime)
+ {
+ FileBasic.LastAccessTime.LowPart = lpLastAccessTime->dwLowDateTime;
+ FileBasic.LastAccessTime.HighPart = lpLastAccessTime->dwHighDateTime;
+ }
+
+ if (lpLastWriteTime)
+ {
+ FileBasic.LastWriteTime.LowPart = lpLastWriteTime->dwLowDateTime;
+ FileBasic.LastWriteTime.HighPart = lpLastWriteTime->dwHighDateTime;
+ }
+
+ Status = NtSetInformationFile(hFile,
+ &IoStatusBlock,
+ &FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ return TRUE;
}