2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/kernel32/file/create.c
5 * PURPOSE: File create/open functions
6 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
7 * GetTempFileName is modified from WINE [ Alexandre Juiliard ]
12 /* INCLUDES *****************************************************************/
15 #include <ddk/ntddk.h>
18 #include <kernel32/li.h>
22 #include <kernel32/kernel32.h>
24 /* FUNCTIONS ****************************************************************/
26 HANDLE STDCALL
CreateFileA(LPCSTR lpFileName
,
27 DWORD dwDesiredAccess
,
29 LPSECURITY_ATTRIBUTES lpSecurityAttributes
,
30 DWORD dwCreationDisposition
,
31 DWORD dwFlagsAndAttributes
,
35 WCHAR FileNameW
[MAX_PATH
];
38 DPRINT("CreateFileA\n");
40 while ((*lpFileName
)!=0 && i
< MAX_PATH
)
42 FileNameW
[i
] = *lpFileName
;
48 return CreateFileW(FileNameW
,dwDesiredAccess
,
51 dwCreationDisposition
,
57 HANDLE STDCALL
CreateFileW(LPCWSTR lpFileName
,
58 DWORD dwDesiredAccess
,
60 LPSECURITY_ATTRIBUTES lpSecurityAttributes
,
61 DWORD dwCreationDisposition
,
62 DWORD dwFlagsAndAttributes
,
68 OBJECT_ATTRIBUTES ObjectAttributes
;
69 IO_STATUS_BLOCK IoStatusBlock
;
70 UNICODE_STRING FileNameString
;
72 WCHAR PathNameW
[MAX_PATH
];
75 WCHAR CurrentDir
[MAX_PATH
];
77 DPRINT("CreateFileW\n");
79 if (!(dwFlagsAndAttributes
& FILE_FLAG_OVERLAPPED
))
81 Flags
|= FILE_SYNCHRONOUS_IO_ALERT
;
84 // lstrcpyW(PathNameW,L"\\??\\");
91 DPRINT("Name %w\n",PathNameW
);
92 if (lpFileName
[0] != L
'\\' && lpFileName
[1] != L
':')
94 Len
= GetCurrentDirectoryW(MAX_PATH
,CurrentDir
);
95 DPRINT("CurrentDir %w\n",CurrentDir
);
96 lstrcatW(PathNameW
,CurrentDir
);
97 DPRINT("Name %w\n",PathNameW
);
99 lstrcatW(PathNameW
,lpFileName
);
100 DPRINT("Name %w\n",PathNameW
);
102 FileNameString
.Length
= lstrlenW( PathNameW
)*sizeof(WCHAR
);
104 if ( FileNameString
.Length
== 0 )
107 if ( FileNameString
.Length
> MAX_PATH
)
110 FileNameString
.Buffer
= (WCHAR
*)PathNameW
;
111 FileNameString
.MaximumLength
= FileNameString
.Length
;
113 ObjectAttributes
.Length
= sizeof(OBJECT_ATTRIBUTES
);
114 ObjectAttributes
.RootDirectory
= NULL
;
115 ObjectAttributes
.ObjectName
= &FileNameString
;
116 ObjectAttributes
.Attributes
= OBJ_CASE_INSENSITIVE
;
117 ObjectAttributes
.SecurityDescriptor
= NULL
;
118 ObjectAttributes
.SecurityQualityOfService
= NULL
;
120 Status
= NtCreateFile(&FileHandle
,
125 dwFlagsAndAttributes
,
127 dwCreationDisposition
,