diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c index a8b6d308ce1..adbc69d1984 100644 --- a/dlls/kernel32/file.c +++ b/dlls/kernel32/file.c @@ -3,6 +3,7 @@ * * Copyright 1993 John Burton * Copyright 1996, 2004 Alexandre Julliard + * Copyright 2008 Jeff Zaroyko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1528,6 +1529,8 @@ BOOL WINAPI DeleteFileW( LPCWSTR path ) UNICODE_STRING nameW; OBJECT_ATTRIBUTES attr; NTSTATUS status; + HANDLE hFile; + IO_STATUS_BLOCK io; TRACE("%s\n", debugstr_w(path) ); @@ -1544,7 +1547,12 @@ BOOL WINAPI DeleteFileW( LPCWSTR path ) attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; - status = NtDeleteFile(&attr); + status = NtCreateFile(&hFile, GENERIC_READ | GENERIC_WRITE | DELETE, + &attr, &io, NULL, 0, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + FILE_OPEN, FILE_DELETE_ON_CLOSE | FILE_NON_DIRECTORY_FILE, NULL, 0); + if (status == STATUS_SUCCESS) status = NtClose(hFile); + RtlFreeUnicodeString( &nameW ); if (status) { diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index 06f4caa221e..1686a4a82c9 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -871,9 +871,9 @@ static void test_DeleteFileW( void ) ret = CreateDirectoryW(pathW, NULL); ok(ret == TRUE, "couldn't create directory deletefile\n"); ret = DeleteFileW(pathW); - todo_wine ok(ret == FALSE, "DeleteFile should fail for empty directories\n"); + ok(ret == FALSE, "DeleteFile should fail for empty directories\n"); ret = RemoveDirectoryW(pathW); - todo_wine ok(ret == TRUE, "expected to remove directory deletefile\n"); + ok(ret == TRUE, "expected to remove directory deletefile\n"); /* test DeleteFile on non-empty directory */ ret = CreateDirectoryW(pathW, NULL); @@ -881,7 +881,7 @@ static void test_DeleteFileW( void ) ret = CreateDirectoryW(pathsubW, NULL); ok(ret == TRUE, "couldn't create directory deletefile\\sub\n"); ret = DeleteFileW(pathW); - todo_wine ok(ret == FALSE, "DeleteFile should fail for non-empty directories\n"); + ok(ret == FALSE, "DeleteFile should fail for non-empty directories\n"); ret = RemoveDirectoryW(pathsubW); ok(ret == TRUE, "expected to remove directory deletefile\\sub\n"); ret = RemoveDirectoryW(pathW); diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 97f9646ffda..36fcc8001b8 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1093,7 +1093,7 @@ static void test_unlink(void) ok(file != NULL, "unable to create test file\n"); if(file) fclose(file); - todo_wine ok(_unlink("test_unlink") != 0, "unlinking a non-empty directory must fail\n"); + ok(_unlink("test_unlink") != 0, "unlinking a non-empty directory must fail\n"); unlink("test_unlink\\empty"); rmdir("test_unlink"); }