Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
CoreFX is using -1 for time fields to ignore when calling SetFileInformationByHandle().
dlls/kernel32/tests/file.c | 2 -- dlls/ntdll/file.c | 8 ++++++-- dlls/ntdll/tests/file.c | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index a2511beef2..9be4ecd136 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -5068,7 +5068,6 @@ todo_wine memset(&basicinfo, 0, sizeof(basicinfo)); basicinfo.LastAccessTime.QuadPart = -1; ret = pSetFileInformationByHandle(file, FileBasicInfo, &basicinfo, sizeof(basicinfo)); -todo_wine ok(ret, "Failed to set basic info, error %d.\n", GetLastError());
memset(&basicinfo, 0, sizeof(basicinfo)); @@ -5402,7 +5401,6 @@ static void test_SetFileTime(void)
memset(&ft1, 0xff, sizeof(ft1)); ret = SetFileTime(hfile, NULL, NULL, &ft1); -todo_wine ok(ret, "SetFileTime error %d\n", GetLastError()); memset(&ft1, 0, sizeof(ft1)); ret = GetFileTime(hfile, NULL, NULL, &ft1); /* get the actual time back */ diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 1cbaa1b293..cd1775a98c 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -2513,12 +2513,16 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, { struct stat st; const FILE_BASIC_INFORMATION *info = ptr; + LARGE_INTEGER mtime, atime;
if ((io->u.Status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) return io->u.Status;
- if (info->LastAccessTime.QuadPart || info->LastWriteTime.QuadPart) - io->u.Status = set_file_times( fd, &info->LastWriteTime, &info->LastAccessTime ); + mtime.QuadPart = info->LastWriteTime.QuadPart == -1 ? 0 : info->LastWriteTime.QuadPart; + atime.QuadPart = info->LastAccessTime.QuadPart == -1 ? 0 : info->LastAccessTime.QuadPart; + + if (atime.QuadPart || mtime.QuadPart) + io->u.Status = set_file_times( fd, &mtime, &atime );
if (io->u.Status == STATUS_SUCCESS && info->FileAttributes) { diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 63854b5482..31fc7ae7b0 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -1332,10 +1332,9 @@ static void test_file_basic_information(void) fbi2.LastWriteTime.QuadPart = -1; U(io).Status = 0xdeadbeef; res = pNtSetInformationFile(h, &io, &fbi2, sizeof fbi2, FileBasicInformation); -todo_wine { ok ( res == STATUS_SUCCESS, "can't set system attribute, NtSetInformationFile returned %x\n", res ); ok ( U(io).Status == STATUS_SUCCESS, "can't set system attribute, io.Status is %x\n", U(io).Status ); -} + memset(&fbi2, 0, sizeof(fbi2)); res = pNtQueryInformationFile(h, &io, &fbi2, sizeof fbi2, FileBasicInformation); ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);