1 /* $Id: delete.c,v 1.16 2004/01/23 21:16:03 ekohl Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/kernel32/file/delete.c
6 * PURPOSE: Deleting files
7 * PROGRAMMER: Ariadne (ariadne@xs4all.nl)
12 /* INCLUDES ****************************************************************/
17 #include "../include/debug.h"
20 /* FUNCTIONS ****************************************************************/
31 UNICODE_STRING FileNameU
;
35 RtlInitAnsiString (&FileName
,
38 /* convert ansi (or oem) string to unicode */
40 RtlAnsiStringToUnicodeString (&FileNameU
,
44 RtlOemStringToUnicodeString (&FileNameU
,
48 Result
= DeleteFileW (FileNameU
.Buffer
);
50 RtlFreeHeap (RtlGetProcessHeap (),
67 FILE_DISPOSITION_INFORMATION FileDispInfo
;
68 OBJECT_ATTRIBUTES ObjectAttributes
;
69 IO_STATUS_BLOCK IoStatusBlock
;
70 UNICODE_STRING NtPathU
;
74 DPRINT("DeleteFileW (lpFileName %S)\n",lpFileName
);
76 if (!RtlDosPathNameToNtPathName_U ((LPWSTR
)lpFileName
,
82 DPRINT("NtPathU \'%wZ\'\n", &NtPathU
);
84 ObjectAttributes
.Length
= sizeof(OBJECT_ATTRIBUTES
);
85 ObjectAttributes
.RootDirectory
= NULL
;
86 ObjectAttributes
.ObjectName
= &NtPathU
;
87 ObjectAttributes
.Attributes
= OBJ_CASE_INSENSITIVE
| OBJ_INHERIT
;
88 ObjectAttributes
.SecurityDescriptor
= NULL
;
89 ObjectAttributes
.SecurityQualityOfService
= NULL
;
91 Status
= NtCreateFile (&FileHandle
,
92 FILE_WRITE_ATTRIBUTES
,
96 FILE_ATTRIBUTE_NORMAL
,
99 FILE_NON_DIRECTORY_FILE
,
103 RtlFreeUnicodeString(&NtPathU
);
105 if (!NT_SUCCESS(Status
))
108 SetLastErrorByStatus (Status
);
112 FileDispInfo
.DoDeleteFile
= TRUE
;
114 Status
= NtSetInformationFile (FileHandle
,
117 sizeof(FILE_DISPOSITION_INFORMATION
),
118 FileDispositionInformation
);
119 if (!NT_SUCCESS(Status
))
122 NtClose (FileHandle
);
123 SetLastErrorByStatus (Status
);
127 Status
= NtClose (FileHandle
);
128 if (!NT_SUCCESS (Status
))
131 SetLastErrorByStatus (Status
);