diff --git a/reactos/dll/win32/kernel32/CMakeLists.txt b/reactos/dll/win32/kernel32/CMakeLists.txt index fcd290795f1..b7f2ffc03d3 100644 --- a/reactos/dll/win32/kernel32/CMakeLists.txt +++ b/reactos/dll/win32/kernel32/CMakeLists.txt @@ -43,7 +43,6 @@ list(APPEND SOURCE client/file/copy.c client/file/console.c client/file/create.c - client/file/curdir.c client/file/delete.c client/file/deviceio.c client/file/dir.c diff --git a/reactos/dll/win32/kernel32/client/file/curdir.c b/reactos/dll/win32/kernel32/client/file/curdir.c deleted file mode 100644 index 9d4d2e344fc..00000000000 --- a/reactos/dll/win32/kernel32/client/file/curdir.c +++ /dev/null @@ -1,388 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/file/curdir.c - * PURPOSE: Current directory functions - * PROGRAMMER: Eric Kohl - * Filip Navara - * Steven Edwards - * Thomas Weidenmueller - * Gunnar Andre' Dalsnes - * UPDATE HISTORY: - * Created 30/09/98 - */ - - -/* INCLUDES ******************************************************************/ - -#include -#define NDEBUG -#include - -#if DBG -DEBUG_CHANNEL(kernel32file); -#endif - -/* GLOBAL VARIABLES **********************************************************/ - -UNICODE_STRING SystemDirectory; -UNICODE_STRING WindowsDirectory; -UNICODE_STRING BaseDefaultPathAppend; -UNICODE_STRING BaseDefaultPath; - - -/* FUNCTIONS *****************************************************************/ - - - - -/* - * @implemented - */ -DWORD -WINAPI -GetCurrentDirectoryA ( - DWORD nBufferLength, - LPSTR lpBuffer - ) -{ - WCHAR BufferW[MAX_PATH]; - DWORD ret; - - ret = GetCurrentDirectoryW(MAX_PATH, BufferW); - - if (!ret) return 0; - if (ret > MAX_PATH) - { - SetLastError(ERROR_FILENAME_EXCED_RANGE); - return 0; - } - - return FilenameW2A_FitOrFail(lpBuffer, nBufferLength, BufferW, ret+1); -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetCurrentDirectoryW ( - DWORD nBufferLength, - LPWSTR lpBuffer - ) -{ - ULONG Length; - - Length = RtlGetCurrentDirectory_U (nBufferLength * sizeof(WCHAR), - lpBuffer); - - return (Length / sizeof (WCHAR)); -} - - - -/* - * @implemented - */ -BOOL -WINAPI -SetCurrentDirectoryA ( - LPCSTR lpPathName - ) -{ - PWCHAR PathNameW; - - TRACE("setcurrdir: %s\n",lpPathName); - - if (!(PathNameW = FilenameA2W(lpPathName, FALSE))) - return FALSE; - - return SetCurrentDirectoryW(PathNameW); -} - - -/* - * @implemented - */ -BOOL -WINAPI -SetCurrentDirectoryW ( - LPCWSTR lpPathName - ) -{ - UNICODE_STRING UnicodeString; - NTSTATUS Status; - - RtlInitUnicodeString (&UnicodeString, - lpPathName); - - Status = RtlSetCurrentDirectory_U (&UnicodeString); - if (!NT_SUCCESS(Status)) - { - BaseSetLastNTError (Status); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - * - * NOTE: Windows returns a dos/short (8.3) path - */ -DWORD -WINAPI -GetTempPathA ( - DWORD nBufferLength, - LPSTR lpBuffer - ) -{ - WCHAR BufferW[MAX_PATH]; - DWORD ret; - - ret = GetTempPathW(MAX_PATH, BufferW); - - if (!ret) - return 0; - - if (ret > MAX_PATH) - { - SetLastError(ERROR_FILENAME_EXCED_RANGE); - return 0; - } - - return FilenameW2A_FitOrFail(lpBuffer, nBufferLength, BufferW, ret+1); -} - - -/* - * @implemented - * - * ripped from wine - */ -DWORD -WINAPI -GetTempPathW ( - DWORD count, - LPWSTR path - ) -{ - static const WCHAR tmp[] = { 'T', 'M', 'P', 0 }; - static const WCHAR temp[] = { 'T', 'E', 'M', 'P', 0 }; - static const WCHAR userprofile[] = { 'U','S','E','R','P','R','O','F','I','L','E',0 }; - WCHAR tmp_path[MAX_PATH]; - UINT ret; - - TRACE("%u,%p\n", count, path); - - if (!(ret = GetEnvironmentVariableW( tmp, tmp_path, MAX_PATH )) && - !(ret = GetEnvironmentVariableW( temp, tmp_path, MAX_PATH )) && - !(ret = GetEnvironmentVariableW( userprofile, tmp_path, MAX_PATH )) && - !(ret = GetWindowsDirectoryW( tmp_path, MAX_PATH ))) - return 0; - - if (ret > MAX_PATH) - { - SetLastError(ERROR_FILENAME_EXCED_RANGE); - return 0; - } - - ret = GetFullPathNameW(tmp_path, MAX_PATH, tmp_path, NULL); - if (!ret) return 0; - - if (ret > MAX_PATH - 2) - { - SetLastError(ERROR_FILENAME_EXCED_RANGE); - return 0; - } - - if (tmp_path[ret-1] != '\\') - { - tmp_path[ret++] = '\\'; - tmp_path[ret] = '\0'; - } - - ret++; /* add space for terminating 0 */ - - if (count) - { - lstrcpynW(path, tmp_path, count); - if (count >= ret) - ret--; /* return length without 0 */ - else if (count < 4) - path[0] = 0; /* avoid returning ambiguous "X:" */ - } - - TRACE("GetTempPathW returning %u, %S\n", ret, path); - return ret; - -} - - -/* - * @implemented - */ -UINT -WINAPI -GetSystemDirectoryA ( - LPSTR lpBuffer, - UINT uSize - ) -{ - return FilenameU2A_FitOrFail(lpBuffer, uSize, &SystemDirectory); -} - - -/* - * @implemented - */ -UINT -WINAPI -GetSystemDirectoryW ( - LPWSTR lpBuffer, - UINT uSize - ) -{ - ULONG Length; - - Length = SystemDirectory.Length / sizeof (WCHAR); - - if (lpBuffer == NULL) - return Length + 1; - - if (uSize > Length) { - memmove (lpBuffer, - SystemDirectory.Buffer, - SystemDirectory.Length); - lpBuffer[Length] = 0; - - return Length; //good: ret chars excl. nullchar - } - - return Length+1; //bad: ret space needed incl. nullchar -} - -/* - * @implemented - */ -UINT -WINAPI -GetWindowsDirectoryA ( - LPSTR lpBuffer, - UINT uSize - ) -{ - return FilenameU2A_FitOrFail(lpBuffer, uSize, &WindowsDirectory); -} - - -/* - * @implemented - */ -UINT -WINAPI -GetWindowsDirectoryW ( - LPWSTR lpBuffer, - UINT uSize - ) -{ - ULONG Length; - - Length = WindowsDirectory.Length / sizeof (WCHAR); - - if (lpBuffer == NULL) - return Length + 1; - - if (uSize > Length) - { - memmove (lpBuffer, - WindowsDirectory.Buffer, - WindowsDirectory.Length); - lpBuffer[Length] = 0; - - return Length; //good: ret chars excl. nullchar - } - - return Length+1; //bad: ret space needed incl. nullchar -} - -/* - * @implemented - */ -UINT -WINAPI -GetSystemWindowsDirectoryA( - LPSTR lpBuffer, - UINT uSize - ) -{ - return GetWindowsDirectoryA( lpBuffer, uSize ); -} - -/* - * @implemented - */ -UINT -WINAPI -GetSystemWindowsDirectoryW( - LPWSTR lpBuffer, - UINT uSize - ) -{ - return GetWindowsDirectoryW( lpBuffer, uSize ); -} - -/* - * @unimplemented - */ -UINT -WINAPI -GetSystemWow64DirectoryW( - LPWSTR lpBuffer, - UINT uSize - ) -{ -#ifdef _WIN64 - ERR("GetSystemWow64DirectoryW is UNIMPLEMENTED!\n"); - return 0; -#else - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -#endif -} - -/* - * @unimplemented - */ -UINT -WINAPI -GetSystemWow64DirectoryA( - LPSTR lpBuffer, - UINT uSize - ) -{ -#ifdef _WIN64 - WCHAR BufferW[MAX_PATH]; - UINT ret; - - ret = GetSystemWow64DirectoryW(BufferW, MAX_PATH); - - if (!ret) return 0; - if (ret > MAX_PATH) - { - SetLastError(ERROR_FILENAME_EXCED_RANGE); - return 0; - } - - return FilenameW2A_FitOrFail(lpBuffer, uSize, BufferW, ret+1); -#else - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -#endif -} - -/* EOF */ diff --git a/reactos/dll/win32/kernel32/client/path.c b/reactos/dll/win32/kernel32/client/path.c index 7c1bf7d539c..bfa5872c860 100644 --- a/reactos/dll/win32/kernel32/client/path.c +++ b/reactos/dll/win32/kernel32/client/path.c @@ -17,6 +17,10 @@ UNICODE_STRING BaseDllDirectory; UNICODE_STRING NoDefaultCurrentDirectoryInExePath = RTL_CONSTANT_STRING(L"NoDefaultCurrentDirectoryInExePath"); +UNICODE_STRING SystemDirectory; +UNICODE_STRING WindowsDirectory; +UNICODE_STRING BaseDefaultPathAppend; +UNICODE_STRING BaseDefaultPath; /* This is bitmask for each illegal filename character */ /* If someone has time, please feel free to use 0b notation */ @@ -452,7 +456,7 @@ NeedCurrentDirectoryForExePathA(IN LPCSTR ExeName) /* * @implemented - * + * * NOTE: Many of these A functions may seem to do rather complex A<->W mapping * beyond what you would usually expect. There are two main reasons: * @@ -1471,4 +1475,293 @@ Quickie: return ReturnLength; } +/* + * @implemented + */ +DWORD +WINAPI +GetCurrentDirectoryA(IN DWORD nBufferLength, + IN LPSTR lpBuffer) +{ + WCHAR BufferW[MAX_PATH]; + DWORD ret; + + ret = GetCurrentDirectoryW(MAX_PATH, BufferW); + + if (!ret) return 0; + if (ret > MAX_PATH) + { + SetLastError(ERROR_FILENAME_EXCED_RANGE); + return 0; + } + + return FilenameW2A_FitOrFail(lpBuffer, nBufferLength, BufferW, ret+1); +} + +/* + * @implemented + */ +DWORD +WINAPI +GetCurrentDirectoryW(IN DWORD nBufferLength, + IN LPWSTR lpBuffer) +{ + ULONG Length; + + Length = RtlGetCurrentDirectory_U (nBufferLength * sizeof(WCHAR), lpBuffer); + return (Length / sizeof (WCHAR)); +} + +/* + * @implemented + */ +BOOL +WINAPI +SetCurrentDirectoryA(IN LPCSTR lpPathName) +{ + PWCHAR PathNameW; + + DPRINT("setcurrdir: %s\n",lpPathName); + + if (!(PathNameW = FilenameA2W(lpPathName, FALSE))) return FALSE; + + return SetCurrentDirectoryW(PathNameW); +} + +/* + * @implemented + */ +BOOL +WINAPI +SetCurrentDirectoryW(IN LPCWSTR lpPathName) +{ + UNICODE_STRING UnicodeString; + NTSTATUS Status; + + RtlInitUnicodeString(&UnicodeString, lpPathName); + + Status = RtlSetCurrentDirectory_U(&UnicodeString); + if (!NT_SUCCESS(Status)) + { + BaseSetLastNTError (Status); + return FALSE; + } + + return TRUE; +} + +/* + * @implemented + * + * NOTE: Windows returns a dos/short (8.3) path + */ +DWORD +WINAPI +GetTempPathA(IN DWORD nBufferLength, + IN LPSTR lpBuffer) +{ + WCHAR BufferW[MAX_PATH]; + DWORD ret; + + ret = GetTempPathW(MAX_PATH, BufferW); + + if (!ret) return 0; + + if (ret > MAX_PATH) + { + SetLastError(ERROR_FILENAME_EXCED_RANGE); + return 0; + } + + return FilenameW2A_FitOrFail(lpBuffer, nBufferLength, BufferW, ret+1); +} + +/* + * @implemented + * + * ripped from wine + */ +DWORD +WINAPI +GetTempPathW(IN DWORD count, + IN LPWSTR path) +{ + static const WCHAR tmp[] = { 'T', 'M', 'P', 0 }; + static const WCHAR temp[] = { 'T', 'E', 'M', 'P', 0 }; + static const WCHAR userprofile[] = { 'U','S','E','R','P','R','O','F','I','L','E',0 }; + WCHAR tmp_path[MAX_PATH]; + UINT ret; + + DPRINT("%u,%p\n", count, path); + + if (!(ret = GetEnvironmentVariableW( tmp, tmp_path, MAX_PATH )) && + !(ret = GetEnvironmentVariableW( temp, tmp_path, MAX_PATH )) && + !(ret = GetEnvironmentVariableW( userprofile, tmp_path, MAX_PATH )) && + !(ret = GetWindowsDirectoryW( tmp_path, MAX_PATH ))) + return 0; + + if (ret > MAX_PATH) + { + SetLastError(ERROR_FILENAME_EXCED_RANGE); + return 0; + } + + ret = GetFullPathNameW(tmp_path, MAX_PATH, tmp_path, NULL); + if (!ret) return 0; + + if (ret > MAX_PATH - 2) + { + SetLastError(ERROR_FILENAME_EXCED_RANGE); + return 0; + } + + if (tmp_path[ret-1] != '\\') + { + tmp_path[ret++] = '\\'; + tmp_path[ret] = '\0'; + } + + ret++; /* add space for terminating 0 */ + + if (count) + { + lstrcpynW(path, tmp_path, count); + if (count >= ret) + ret--; /* return length without 0 */ + else if (count < 4) + path[0] = 0; /* avoid returning ambiguous "X:" */ + } + + DPRINT("GetTempPathW returning %u, %S\n", ret, path); + return ret; +} + +/* + * @implemented + */ +UINT +WINAPI +GetSystemDirectoryA(IN LPSTR lpBuffer, + IN UINT uSize) +{ + return FilenameU2A_FitOrFail(lpBuffer, uSize, &SystemDirectory); +} + +/* + * @implemented + */ +UINT +WINAPI +GetSystemDirectoryW(IN LPWSTR lpBuffer, + IN UINT uSize) +{ + ULONG Length; + + Length = SystemDirectory.Length / sizeof (WCHAR); + + if (lpBuffer == NULL) return Length + 1; + + if (uSize > Length) + { + memmove(lpBuffer, SystemDirectory.Buffer, SystemDirectory.Length); + lpBuffer[Length] = 0; + + return Length; //good: ret chars excl. nullchar + } + + return Length+1; //bad: ret space needed incl. nullchar +} + +/* + * @implemented + */ +UINT +WINAPI +GetWindowsDirectoryA(IN LPSTR lpBuffer, + IN UINT uSize) +{ + return FilenameU2A_FitOrFail(lpBuffer, uSize, &WindowsDirectory); +} + +/* + * @implemented + */ +UINT +WINAPI +GetWindowsDirectoryW(IN LPWSTR lpBuffer, + IN UINT uSize) +{ + ULONG Length; + + Length = WindowsDirectory.Length / sizeof (WCHAR); + + if (lpBuffer == NULL) return Length + 1; + + if (uSize > Length) + { + memmove(lpBuffer, WindowsDirectory.Buffer, WindowsDirectory.Length); + lpBuffer[Length] = 0; + + return Length; //good: ret chars excl. nullchar + } + + return Length+1; //bad: ret space needed incl. nullchar +} + +/* + * @implemented + */ +UINT +WINAPI +GetSystemWindowsDirectoryA(IN LPSTR lpBuffer, + IN UINT uSize) +{ + return GetWindowsDirectoryA(lpBuffer, uSize); +} + +/* + * @implemented + */ +UINT +WINAPI +GetSystemWindowsDirectoryW(IN LPWSTR lpBuffer, + IN UINT uSize) +{ + return GetWindowsDirectoryW(lpBuffer, uSize); +} + +/* + * @unimplemented + */ +UINT +WINAPI +GetSystemWow64DirectoryW(IN LPWSTR lpBuffer, + IN UINT uSize) +{ +#ifdef _WIN64 + UNIMPLEMENTED; + return 0; +#else + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +#endif +} + +/* + * @unimplemented + */ +UINT +WINAPI +GetSystemWow64DirectoryA(IN LPSTR lpBuffer, + IN UINT uSize) +{ +#ifdef _WIN64 + UNIMPLEMENTED; + return 0; +#else + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +#endif +} + /* EOF */ diff --git a/reactos/dll/win32/kernel32/kernel32.rbuild b/reactos/dll/win32/kernel32/kernel32.rbuild index a31603d8444..7094e46a669 100644 --- a/reactos/dll/win32/kernel32/kernel32.rbuild +++ b/reactos/dll/win32/kernel32/kernel32.rbuild @@ -61,7 +61,6 @@ copy.c console.c create.c - curdir.c delete.c deviceio.c dir.c