From aebcbf0f6e10d80b04bc4a3dcd3e8ca55dfd60d0 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Wed, 27 Feb 2008 19:58:40 +0800 Subject: [PATCH] kernel32: Return upper cased drive letters in paths, some applications depend on it. --- dlls/kernel32/process.c | 2 +- dlls/kernel32/tests/path.c | 83 ++++++++++++++++++++++++++++++++++++++ dlls/ntdll/path.c | 2 +- 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 8e7e675d8d8..b3bf535d6f7 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -690,7 +690,7 @@ static void init_windows_dirs(void) static const WCHAR windirW[] = {'w','i','n','d','i','r',0}; static const WCHAR winsysdirW[] = {'w','i','n','s','y','s','d','i','r',0}; - static const WCHAR default_windirW[] = {'c',':','\\','w','i','n','d','o','w','s',0}; + static const WCHAR default_windirW[] = {'C',':','\\','w','i','n','d','o','w','s',0}; static const WCHAR default_sysdirW[] = {'\\','s','y','s','t','e','m','3','2',0}; DWORD len; diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 05111a8c498..dfb77481c99 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -727,6 +727,7 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive) "GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE); /* Otherwise insert the missing leading slash */ if( otherDrive != NOT_A_VALID_DRIVE) { + /* FIXME: this test assumes that current directory on other drive is root */ sprintf(tmpstr,"%c:%s\\%s",otherDrive,SHORTDIR,SHORTFILE); ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed for %s\n", tmpstr); sprintf(tmpstr,"%c:\\%s\\%s",otherDrive,SHORTDIR,SHORTFILE); @@ -1157,6 +1158,87 @@ static void test_NeedCurrentDirectoryForExePathW(void) ok(!pNeedCurrentDirectoryForExePathW(cmdname), "returned TRUE for \"cmd.exe\"\n"); } +/* Call various path/file name retrieving APIs and check the case of + * the returned drive letter. Some apps (for instance Adobe Photoshop CS3 + * installer) depend on the driver letter being in upper case. + */ +static void test_drive_letter_case(void) +{ + UINT ret; + char buf[MAX_PATH]; + +#define is_upper_case_letter(a) ((a) >= 'A' && (a) <= 'Z') + + memset(buf, 0, sizeof(buf)); + SetLastError(0xdeadbeef); + ret = GetWindowsDirectory(buf, sizeof(buf)); + ok(ret, "GetWindowsDirectory error %u\n", GetLastError()); + ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret); + ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]); + ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]); + + /* re-use the buffer returned by GetFullPathName */ + buf[2] = '/'; + SetLastError(0xdeadbeef); + ret = GetFullPathName(buf + 2, sizeof(buf), buf, NULL); + ok(ret, "GetFullPathName error %u\n", GetLastError()); + ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret); + ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]); + ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]); + + memset(buf, 0, sizeof(buf)); + SetLastError(0xdeadbeef); + ret = GetSystemDirectory(buf, sizeof(buf)); + ok(ret, "GetSystemDirectory error %u\n", GetLastError()); + ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret); + ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]); + ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]); + + memset(buf, 0, sizeof(buf)); + SetLastError(0xdeadbeef); + ret = GetCurrentDirectory(sizeof(buf), buf); + ok(ret, "GetCurrentDirectory error %u\n", GetLastError()); + ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret); + ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]); + ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]); + + memset(buf, 0, sizeof(buf)); + SetLastError(0xdeadbeef); + ret = GetTempPath(sizeof(buf), buf); + ok(ret, "GetTempPath error %u\n", GetLastError()); + ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret); + ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]); + ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]); + + memset(buf, 0, sizeof(buf)); + SetLastError(0xdeadbeef); + ret = GetFullPathName(".", sizeof(buf), buf, NULL); + ok(ret, "GetFullPathName error %u\n", GetLastError()); + ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret); + ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]); + ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]); + + /* re-use the buffer returned by GetFullPathName */ + SetLastError(0xdeadbeef); + ret = GetShortPathName(buf, buf, sizeof(buf)); + ok(ret, "GetShortPathName error %u\n", GetLastError()); + ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret); + ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]); + ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]); + + if (pGetLongPathNameA) + { + /* re-use the buffer returned by GetShortPathName */ + SetLastError(0xdeadbeef); + ret = pGetLongPathNameA(buf, buf, sizeof(buf)); + ok(ret, "GetLongPathNameA error %u\n", GetLastError()); + ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret); + ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]); + ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]); + } +#undef is_upper_case_letter +} + START_TEST(path) { CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive; @@ -1188,4 +1270,5 @@ START_TEST(path) { test_NeedCurrentDirectoryForExePathW(); } + test_drive_letter_case(); } diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c index db4cd102ecd..73a77a85c4a 100644 --- a/dlls/ntdll/path.c +++ b/dlls/ntdll/path.c @@ -1025,7 +1025,7 @@ NTSTATUS WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING* dir) */ NTSTATUS wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRING *nt ) { - static const WCHAR prefixW[] = {'\\','?','?','\\','a',':','\\'}; + static const WCHAR prefixW[] = {'\\','?','?','\\','A',':','\\'}; unsigned int lenW, lenA = name->Length; const char *path = name->Buffer; char *cwd;