kernel32: Modify DeleteFileW to fail on directories.
This commit is contained in:
parent
87292d81ee
commit
22a33168c9
|
@ -3,6 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright 1993 John Burton
|
* Copyright 1993 John Burton
|
||||||
* Copyright 1996, 2004 Alexandre Julliard
|
* Copyright 1996, 2004 Alexandre Julliard
|
||||||
|
* Copyright 2008 Jeff Zaroyko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1528,6 +1529,8 @@ BOOL WINAPI DeleteFileW( LPCWSTR path )
|
||||||
UNICODE_STRING nameW;
|
UNICODE_STRING nameW;
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
HANDLE hFile;
|
||||||
|
IO_STATUS_BLOCK io;
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(path) );
|
TRACE("%s\n", debugstr_w(path) );
|
||||||
|
|
||||||
|
@ -1544,7 +1547,12 @@ BOOL WINAPI DeleteFileW( LPCWSTR path )
|
||||||
attr.SecurityDescriptor = NULL;
|
attr.SecurityDescriptor = NULL;
|
||||||
attr.SecurityQualityOfService = 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 );
|
RtlFreeUnicodeString( &nameW );
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -871,9 +871,9 @@ static void test_DeleteFileW( void )
|
||||||
ret = CreateDirectoryW(pathW, NULL);
|
ret = CreateDirectoryW(pathW, NULL);
|
||||||
ok(ret == TRUE, "couldn't create directory deletefile\n");
|
ok(ret == TRUE, "couldn't create directory deletefile\n");
|
||||||
ret = DeleteFileW(pathW);
|
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);
|
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 */
|
/* test DeleteFile on non-empty directory */
|
||||||
ret = CreateDirectoryW(pathW, NULL);
|
ret = CreateDirectoryW(pathW, NULL);
|
||||||
|
@ -881,7 +881,7 @@ static void test_DeleteFileW( void )
|
||||||
ret = CreateDirectoryW(pathsubW, NULL);
|
ret = CreateDirectoryW(pathsubW, NULL);
|
||||||
ok(ret == TRUE, "couldn't create directory deletefile\\sub\n");
|
ok(ret == TRUE, "couldn't create directory deletefile\\sub\n");
|
||||||
ret = DeleteFileW(pathW);
|
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);
|
ret = RemoveDirectoryW(pathsubW);
|
||||||
ok(ret == TRUE, "expected to remove directory deletefile\\sub\n");
|
ok(ret == TRUE, "expected to remove directory deletefile\\sub\n");
|
||||||
ret = RemoveDirectoryW(pathW);
|
ret = RemoveDirectoryW(pathW);
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ static void test_unlink(void)
|
||||||
ok(file != NULL, "unable to create test file\n");
|
ok(file != NULL, "unable to create test file\n");
|
||||||
if(file)
|
if(file)
|
||||||
fclose(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");
|
unlink("test_unlink\\empty");
|
||||||
rmdir("test_unlink");
|
rmdir("test_unlink");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue