diff --git a/dlls/kernel/file.c b/dlls/kernel/file.c index b5b7c49ed0b..807fbb4dde9 100644 --- a/dlls/kernel/file.c +++ b/dlls/kernel/file.c @@ -1362,16 +1362,32 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing, */ BOOL WINAPI DeleteFileW( LPCWSTR path ) { - HANDLE hFile; + UNICODE_STRING nameW; + OBJECT_ATTRIBUTES attr; + NTSTATUS status; TRACE("%s\n", debugstr_w(path) ); - hFile = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0 ); - if (hFile == INVALID_HANDLE_VALUE) return FALSE; + if (!RtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL )) + { + SetLastError( ERROR_PATH_NOT_FOUND ); + return FALSE; + } - CloseHandle(hFile); /* last close will delete the file */ + attr.Length = sizeof(attr); + attr.RootDirectory = 0; + attr.Attributes = OBJ_CASE_INSENSITIVE; + attr.ObjectName = &nameW; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + + status = NtDeleteFile(&attr); + RtlFreeUnicodeString( &nameW ); + if (status) + { + SetLastError( RtlNtStatusToDosError(status) ); + return FALSE; + } return TRUE; } diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 4b7b9190a53..e1ee49fa98b 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -1647,8 +1647,17 @@ NTSTATUS WINAPI NtCreateNamedPipeFile( PHANDLE FileHandle, ULONG DesiredAccess, */ NTSTATUS WINAPI NtDeleteFile( POBJECT_ATTRIBUTES ObjectAttributes ) { - FIXME("%p\n", ObjectAttributes); - return STATUS_NOT_IMPLEMENTED; + NTSTATUS status; + HANDLE hFile; + IO_STATUS_BLOCK io; + + TRACE("%p\n", ObjectAttributes); + status = NtCreateFile( &hFile, GENERIC_READ | GENERIC_WRITE, ObjectAttributes, + &io, NULL, 0, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + FILE_OPEN, FILE_DELETE_ON_CLOSE, NULL, 0 ); + if (status == STATUS_SUCCESS) status = NtClose(hFile); + return status; } /******************************************************************