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