mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 07:13:23 +00:00
Fixed CreateDirectoryExW.
svn path=/trunk/; revision=489
This commit is contained in:
parent
0495cfd8d4
commit
cf7d159791
1 changed files with 119 additions and 85 deletions
|
@ -22,6 +22,10 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <kernel32/kernel32.h>
|
#include <kernel32/kernel32.h>
|
||||||
|
|
||||||
|
/* EXTERNS ******************************************************************/
|
||||||
|
|
||||||
|
DWORD STDCALL GetCurrentDriveW(DWORD nBufferLength, PWSTR lpBuffer);
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
WINBOOL STDCALL CreateDirectoryA(LPCSTR lpPathName,
|
WINBOOL STDCALL CreateDirectoryA(LPCSTR lpPathName,
|
||||||
|
@ -88,6 +92,9 @@ WINBOOL STDCALL CreateDirectoryExW(LPCWSTR lpTemplateDirectory,
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING DirectoryNameString;
|
UNICODE_STRING DirectoryNameString;
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
WCHAR PathNameW[MAX_PATH];
|
||||||
|
WCHAR DirectoryNameW[MAX_PATH];
|
||||||
|
UINT Len = 0;
|
||||||
|
|
||||||
DPRINT("lpTemplateDirectory %w lpNewDirectory %w lpSecurityAttributes %p\n",
|
DPRINT("lpTemplateDirectory %w lpNewDirectory %w lpSecurityAttributes %p\n",
|
||||||
lpTemplateDirectory, lpNewDirectory, lpSecurityAttributes);
|
lpTemplateDirectory, lpNewDirectory, lpSecurityAttributes);
|
||||||
|
@ -99,9 +106,52 @@ WINBOOL STDCALL CreateDirectoryExW(LPCWSTR lpTemplateDirectory,
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectoryNameString.Length = lstrlenW(lpNewDirectory)*sizeof(WCHAR);
|
if (lpNewDirectory[1] == (WCHAR)':')
|
||||||
DirectoryNameString.Buffer = (WCHAR *)lpNewDirectory;
|
{
|
||||||
DirectoryNameString.MaximumLength = DirectoryNameString.Length+sizeof(WCHAR);
|
wcscpy(PathNameW, lpNewDirectory);
|
||||||
|
}
|
||||||
|
else if (wcslen(lpNewDirectory) > 4 &&
|
||||||
|
lpNewDirectory[0] == (WCHAR)'\\' &&
|
||||||
|
lpNewDirectory[1] == (WCHAR)'\\' &&
|
||||||
|
lpNewDirectory[2] == (WCHAR)'.' &&
|
||||||
|
lpNewDirectory[3] == (WCHAR)'\\')
|
||||||
|
{
|
||||||
|
wcscpy(PathNameW, lpNewDirectory);
|
||||||
|
}
|
||||||
|
else if (lpNewDirectory[0] == (WCHAR)'\\')
|
||||||
|
{
|
||||||
|
GetCurrentDriveW(MAX_PATH,PathNameW);
|
||||||
|
wcscat(PathNameW, lpNewDirectory);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Len = GetCurrentDirectoryW(MAX_PATH,PathNameW);
|
||||||
|
if ( Len == 0 )
|
||||||
|
return NULL;
|
||||||
|
if ( PathNameW[Len-1] != L'\\' ) {
|
||||||
|
PathNameW[Len] = L'\\';
|
||||||
|
PathNameW[Len+1] = 0;
|
||||||
|
}
|
||||||
|
wcscat(PathNameW,lpNewDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
DirectoryNameW[0] = '\\';
|
||||||
|
DirectoryNameW[1] = '?';
|
||||||
|
DirectoryNameW[2] = '?';
|
||||||
|
DirectoryNameW[3] = '\\';
|
||||||
|
DirectoryNameW[4] = 0;
|
||||||
|
wcscat(DirectoryNameW,PathNameW);
|
||||||
|
|
||||||
|
DirectoryNameString.Length = wcslen (DirectoryNameW)*sizeof(WCHAR);
|
||||||
|
|
||||||
|
if ( DirectoryNameString.Length == 0 )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ( DirectoryNameString.Length > MAX_PATH*sizeof(WCHAR) )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
DirectoryNameString.Buffer = (WCHAR *)DirectoryNameW;
|
||||||
|
DirectoryNameString.MaximumLength = DirectoryNameString.Length + sizeof(WCHAR);
|
||||||
|
|
||||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||||
ObjectAttributes.RootDirectory = NULL;
|
ObjectAttributes.RootDirectory = NULL;
|
||||||
|
@ -118,7 +168,7 @@ WINBOOL STDCALL CreateDirectoryExW(LPCWSTR lpTemplateDirectory,
|
||||||
FILE_ATTRIBUTE_DIRECTORY,
|
FILE_ATTRIBUTE_DIRECTORY,
|
||||||
0,
|
0,
|
||||||
FILE_CREATE,
|
FILE_CREATE,
|
||||||
0,
|
FILE_DIRECTORY_FILE,
|
||||||
NULL,
|
NULL,
|
||||||
0);
|
0);
|
||||||
DPRINT("errCode: %x\n", errCode);
|
DPRINT("errCode: %x\n", errCode);
|
||||||
|
@ -579,8 +629,6 @@ DWORD STDCALL SearchPathW(LPCWSTR lpPath,
|
||||||
* On failure, zero.
|
* On failure, zero.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS errCode;
|
NTSTATUS errCode;
|
||||||
DWORD retCode = 0;
|
DWORD retCode = 0;
|
||||||
HANDLE FileHandle = NULL;
|
HANDLE FileHandle = NULL;
|
||||||
|
@ -597,9 +645,7 @@ DWORD STDCALL SearchPathW(LPCWSTR lpPath,
|
||||||
|
|
||||||
dprintf("SearchPath\n");
|
dprintf("SearchPath\n");
|
||||||
|
|
||||||
|
|
||||||
if ( lpPath == NULL ) {
|
if ( lpPath == NULL ) {
|
||||||
|
|
||||||
// check the directory from which the application loaded
|
// check the directory from which the application loaded
|
||||||
|
|
||||||
if ( GetCurrentDirectoryW( MAX_PATH, BufferW ) > 0 ) {
|
if ( GetCurrentDirectoryW( MAX_PATH, BufferW ) > 0 ) {
|
||||||
|
@ -633,15 +679,10 @@ DWORD STDCALL SearchPathW(LPCWSTR lpPath,
|
||||||
if ( EnvironmentBufferW[i] != 0 )
|
if ( EnvironmentBufferW[i] != 0 )
|
||||||
retCode = SearchPathW(&EnvironmentBufferW[i],lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart );
|
retCode = SearchPathW(&EnvironmentBufferW[i],lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart );
|
||||||
i += lstrlenW(&EnvironmentBufferW[i]) + 1;
|
i += lstrlenW(&EnvironmentBufferW[i]) + 1;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(),0,EnvironmentBufferW);
|
HeapFree(GetProcessHeap(),0,EnvironmentBufferW);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return retCode;
|
return retCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -666,14 +707,11 @@ DWORD STDCALL SearchPathW(LPCWSTR lpPath,
|
||||||
else
|
else
|
||||||
wcscpy(FileAndExtensionW,lpFileName);
|
wcscpy(FileAndExtensionW,lpFileName);
|
||||||
|
|
||||||
|
|
||||||
lstrcatW(BufferW,L"\\??\\");
|
lstrcatW(BufferW,L"\\??\\");
|
||||||
lstrcatW(BufferW,lpPath);
|
lstrcatW(BufferW,lpPath);
|
||||||
|
|
||||||
|
|
||||||
//printf("%S\n",FileAndExtensionW);
|
//printf("%S\n",FileAndExtensionW);
|
||||||
|
|
||||||
|
|
||||||
i = wcslen(BufferW);
|
i = wcslen(BufferW);
|
||||||
if ( BufferW[i-1] != L'\\' ) {
|
if ( BufferW[i-1] != L'\\' ) {
|
||||||
BufferW[i] = L'\\';
|
BufferW[i] = L'\\';
|
||||||
|
@ -688,9 +726,6 @@ DWORD STDCALL SearchPathW(LPCWSTR lpPath,
|
||||||
PathString.Length = lstrlenW(PathString.Buffer)*sizeof(WCHAR);
|
PathString.Length = lstrlenW(PathString.Buffer)*sizeof(WCHAR);
|
||||||
PathString.MaximumLength = PathString.Length + sizeof(WCHAR);
|
PathString.MaximumLength = PathString.Length + sizeof(WCHAR);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||||
ObjectAttributes.RootDirectory = NULL;
|
ObjectAttributes.RootDirectory = NULL;
|
||||||
ObjectAttributes.ObjectName = &PathString;
|
ObjectAttributes.ObjectName = &PathString;
|
||||||
|
@ -707,7 +742,6 @@ DWORD STDCALL SearchPathW(LPCWSTR lpPath,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if ( !NT_SUCCESS(errCode) ) {
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue