Fixed bug (please don't alter functions without debugging)

svn path=/trunk/; revision=172
This commit is contained in:
David Welch 1999-01-17 17:12:19 +00:00
parent 804bfa6fb9
commit 51f310e703

View file

@ -4,13 +4,19 @@
* FILE: lib/kernel32/file/create.c * FILE: lib/kernel32/file/create.c
* PURPOSE: Directory functions * PURPOSE: Directory functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl) * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
GetTempFileName is modified from WINE [ Alexandre Juiliard ] * GetTempFileName is modified from WINE [ Alexandre Juiliard ]
* UPDATE HISTORY: * UPDATE HISTORY:
* Created 01/11/98 * Created 01/11/98
* Removed use of SearchPath (not used by Windows)
*/ */
/*
* NOTES: Please don't alter without debugging
*
*/
/* INCLUDES *****************************************************************/
#undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <wstring.h> #include <wstring.h>
@ -18,9 +24,11 @@
#include <ddk/li.h> #include <ddk/li.h>
#include <ddk/rtl.h> #include <ddk/rtl.h>
#define NDEBUG //#define NDEBUG
#include <kernel32/kernel32.h> #include <kernel32/kernel32.h>
/* FUNCTIONS ****************************************************************/
HANDLE STDCALL CreateFileA(LPCSTR lpFileName, HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
DWORD dwDesiredAccess, DWORD dwDesiredAccess,
DWORD dwShareMode, DWORD dwShareMode,
@ -33,7 +41,7 @@ HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
WCHAR FileNameW[MAX_PATH]; WCHAR FileNameW[MAX_PATH];
ULONG i = 0; ULONG i = 0;
// OutputDebugStringA("CreateFileA\n"); DPRINT("CreateFileA(lpFileName %s)\n",lpFileName);
while ((*lpFileName)!=0 && i < MAX_PATH) while ((*lpFileName)!=0 && i < MAX_PATH)
{ {
@ -61,8 +69,7 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
HANDLE hTemplateFile) HANDLE hTemplateFile)
{ {
HANDLE FileHandle; HANDLE FileHandle;
NTSTATUS Status; NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IoStatusBlock;
UNICODE_STRING FileNameString; UNICODE_STRING FileNameString;
@ -72,48 +79,39 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
WCHAR *FilePart; WCHAR *FilePart;
UINT Len = 0; UINT Len = 0;
DPRINT("CreateFileW(lpFileName %w)\n",lpFileName);
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED)) if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
{ {
Flags |= FILE_SYNCHRONOUS_IO_ALERT; Flags |= FILE_SYNCHRONOUS_IO_ALERT;
} }
// dprintf("CreateFile %S\n",lpFileName); if ( lpFileName[0] == L'\\' || lpFileName[1] == L':')
{
if ( lpFileName[0] == L'\\' || lpFileName[1] == L':') {
wcscpy(PathNameW,lpFileName); wcscpy(PathNameW,lpFileName);
} }
else if ( ( ( dwCreationDisposition & OPEN_EXISTING ) == OPEN_EXISTING ) || ( ( dwCreationDisposition & TRUNCATE_EXISTING ) == TRUNCATE_EXISTING ) ) { else
dprintf("Before SearchPath\n"); {
Len = SearchPathW(NULL,lpFileName,NULL,MAX_PATH,PathNameW,&FilePart);
if ( Len == 0 )
return NULL;
}
else {
Len = GetCurrentDirectoryW(MAX_PATH,PathNameW); Len = GetCurrentDirectoryW(MAX_PATH,PathNameW);
if ( Len == 0 ) if ( Len == 0 )
return NULL; return NULL;
if ( PathNameW[Len-1] != L'\\' ) { if ( PathNameW[Len-1] != L'\\' ) {
PathNameW[Len] = L'\\'; PathNameW[Len] = L'\\';
PathNameW[Len+1] = 0; PathNameW[Len+1] = 0;
} }
wcscat(PathNameW,lpFileName); wcscat(PathNameW,lpFileName);
} }
if ( PathNameW[1] == L':' ) { FileNameW[0] = '\\';
FileNameW[0] = '\\'; FileNameW[1] = '?';
FileNameW[1] = '?'; FileNameW[2] = '?';
FileNameW[2] = '?'; FileNameW[3] = '\\';
FileNameW[3] = '\\'; FileNameW[4] = 0;
FileNameW[4] = 0; wcscat(FileNameW,PathNameW);
wcscat(FileNameW,PathNameW);
}
else
wcscpy(FileNameW,PathNameW);
FileNameString.Length = wcslen( FileNameW)*sizeof(WCHAR); FileNameString.Length = wcslen( FileNameW)*sizeof(WCHAR);
if ( FileNameString.Length == 0 ) if ( FileNameString.Length == 0 )
return NULL; return NULL;
@ -130,7 +128,7 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
ObjectAttributes.SecurityDescriptor = NULL; ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL; ObjectAttributes.SecurityQualityOfService = NULL;
// dprintf("File Name %S\n",FileNameW); DPRINT("File Name %w\n",FileNameW);
Status = ZwCreateFile(&FileHandle, Status = ZwCreateFile(&FileHandle,
dwDesiredAccess, dwDesiredAccess,