Module: wine Branch: master Commit: 62c4ffb4d6b85280ac8406c1af73c1db07fe3130 URL: http://source.winehq.org/git/wine.git/?a=commit;h=62c4ffb4d6b85280ac8406c1af...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Oct 9 23:57:53 2017 +0200
shlwapi: Support NT prefix paths in PathGetDriveNumberW.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/shlwapi/path.c | 26 +++++++++++++++++--------- dlls/shlwapi/tests/path.c | 12 ++++++++++++ 2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index 3c07bb8..89a3572 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -538,17 +538,25 @@ int WINAPI PathGetDriveNumberA(LPCSTR lpszPath) * * See PathGetDriveNumberA. */ -int WINAPI PathGetDriveNumberW(LPCWSTR lpszPath) +int WINAPI PathGetDriveNumberW(const WCHAR *path) { - TRACE ("(%s)\n",debugstr_w(lpszPath)); + WCHAR drive;
- if (lpszPath) - { - WCHAR tl = tolowerW(lpszPath[0]); - if (tl >= 'a' && tl <= 'z' && lpszPath[1] == ':') - return tl - 'a'; - } - return -1; + static const WCHAR nt_prefixW[] = {'\','\','?','\'}; + + TRACE("(%s)\n", debugstr_w(path)); + + if (!path) + return -1; + + if (!strncmpW(path, nt_prefixW, 4)) + path += 4; + + drive = tolowerW(path[0]); + if (drive < 'a' || drive > 'z' || path[1] != ':') + return -1; + + return drive - 'a'; }
/************************************************************************* diff --git a/dlls/shlwapi/tests/path.c b/dlls/shlwapi/tests/path.c index f780a78..57fdfdd 100644 --- a/dlls/shlwapi/tests/path.c +++ b/dlls/shlwapi/tests/path.c @@ -1429,6 +1429,11 @@ static void test_PathGetDriveNumber(void) static const CHAR test2A[] = "file:////b:\test.file"; static const CHAR test3A[] = "file:///c:\test.file"; static const CHAR test4A[] = "file:\\c:\test.file"; + static const CHAR test5A[] = "\\?\C:\dir\file.txt"; + static const WCHAR test1W[] = + {'a',':','\',0}; + static const WCHAR test5W[] = + {'\','\','?','\','C',':','\','d','i','r','\','f','i','l','e',0}; int ret;
SetLastError(0xdeadbeef); @@ -1438,12 +1443,19 @@ static void test_PathGetDriveNumber(void)
ret = PathGetDriveNumberA(test1A); ok(ret == 0, "got %d\n", ret); + ret = PathGetDriveNumberW(test1W); + ok(ret == 0, "got %d\n", ret); ret = PathGetDriveNumberA(test2A); ok(ret == -1, "got %d\n", ret); ret = PathGetDriveNumberA(test3A); ok(ret == -1, "got %d\n", ret); ret = PathGetDriveNumberA(test4A); ok(ret == -1, "got %d\n", ret); + + ret = PathGetDriveNumberA(test5A); + ok(ret == -1, "got %d\n", ret); + ret = PathGetDriveNumberW(test5W); + ok(ret == 2 || broken(ret == -1) /* winxp */, "got = %d\n", ret); }
static void test_PathUnExpandEnvStrings(void)