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
* PURPOSE: Directory functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
GetTempFileName is modified from WINE [ Alexandre Juiliard ]
* GetTempFileName is modified from WINE [ Alexandre Juiliard ]
* UPDATE HISTORY:
* 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 <ddk/ntddk.h>
#include <wstring.h>
@ -18,9 +24,11 @@
#include <ddk/li.h>
#include <ddk/rtl.h>
#define NDEBUG
//#define NDEBUG
#include <kernel32/kernel32.h>
/* FUNCTIONS ****************************************************************/
HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
@ -33,7 +41,7 @@ HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
WCHAR FileNameW[MAX_PATH];
ULONG i = 0;
// OutputDebugStringA("CreateFileA\n");
DPRINT("CreateFileA(lpFileName %s)\n",lpFileName);
while ((*lpFileName)!=0 && i < MAX_PATH)
{
@ -62,7 +70,6 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
{
HANDLE FileHandle;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
UNICODE_STRING FileNameString;
@ -72,23 +79,19 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
WCHAR *FilePart;
UINT Len = 0;
DPRINT("CreateFileW(lpFileName %w)\n",lpFileName);
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
{
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);
}
else if ( ( ( dwCreationDisposition & OPEN_EXISTING ) == OPEN_EXISTING ) || ( ( dwCreationDisposition & TRUNCATE_EXISTING ) == TRUNCATE_EXISTING ) ) {
dprintf("Before SearchPath\n");
Len = SearchPathW(NULL,lpFileName,NULL,MAX_PATH,PathNameW,&FilePart);
if ( Len == 0 )
return NULL;
}
else {
else
{
Len = GetCurrentDirectoryW(MAX_PATH,PathNameW);
if ( Len == 0 )
return NULL;
@ -99,17 +102,12 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
wcscat(PathNameW,lpFileName);
}
if ( PathNameW[1] == L':' ) {
FileNameW[0] = '\\';
FileNameW[1] = '?';
FileNameW[2] = '?';
FileNameW[3] = '\\';
FileNameW[4] = 0;
wcscat(FileNameW,PathNameW);
}
else
wcscpy(FileNameW,PathNameW);
FileNameString.Length = wcslen( FileNameW)*sizeof(WCHAR);
@ -130,7 +128,7 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
// dprintf("File Name %S\n",FileNameW);
DPRINT("File Name %w\n",FileNameW);
Status = ZwCreateFile(&FileHandle,
dwDesiredAccess,