Commit 22a33168 authored by Jeff Zaroyko's avatar Jeff Zaroyko Committed by Alexandre Julliard

kernel32: Modify DeleteFileW to fail on directories.

parent 87292d81
......@@ -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)
{
......
......@@ -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);
......
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment