ntdll: Ignore -1 time value same as 0 when setting file times.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-08-09 09:50:34 +03:00 committed by Alexandre Julliard
parent 3172b854ae
commit 2a15f77b49
3 changed files with 7 additions and 6 deletions

View File

@ -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 */

View File

@ -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)
{

View File

@ -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);