2003-01-09 01:50:17 +01:00
|
|
|
/* Unit test suite for Path functions
|
|
|
|
*
|
|
|
|
* Copyright 2002 Matthew Mastracci
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-01-09 01:50:17 +01:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-01-09 01:50:17 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2003-01-09 01:50:17 +01:00
|
|
|
#include "winbase.h"
|
2003-05-13 02:29:34 +02:00
|
|
|
#include "winreg.h"
|
2003-01-09 01:50:17 +01:00
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "wininet.h"
|
|
|
|
|
2015-10-15 12:07:02 +02:00
|
|
|
static BOOL (WINAPI *pPathIsValidCharA)(char,DWORD);
|
|
|
|
static BOOL (WINAPI *pPathIsValidCharW)(WCHAR,DWORD);
|
2006-06-23 15:21:02 +02:00
|
|
|
static LPWSTR (WINAPI *pPathCombineW)(LPWSTR, LPCWSTR, LPCWSTR);
|
2010-01-30 22:59:01 +01:00
|
|
|
static HRESULT (WINAPI *pPathCreateFromUrlA)(LPCSTR, LPSTR, LPDWORD, DWORD);
|
|
|
|
static HRESULT (WINAPI *pPathCreateFromUrlW)(LPCWSTR, LPWSTR, LPDWORD, DWORD);
|
2012-10-01 03:29:55 +02:00
|
|
|
static HRESULT (WINAPI *pPathCreateFromUrlAlloc)(LPCWSTR, LPWSTR*, DWORD);
|
2010-03-03 10:38:39 +01:00
|
|
|
static BOOL (WINAPI *pPathAppendA)(LPSTR, LPCSTR);
|
2013-11-04 10:39:09 +01:00
|
|
|
static BOOL (WINAPI *pPathUnExpandEnvStringsA)(LPCSTR, LPSTR, UINT);
|
|
|
|
static BOOL (WINAPI *pPathUnExpandEnvStringsW)(LPCWSTR, LPWSTR, UINT);
|
2014-07-02 17:55:02 +02:00
|
|
|
static BOOL (WINAPI *pPathIsRelativeA)(LPCSTR);
|
|
|
|
static BOOL (WINAPI *pPathIsRelativeW)(LPCWSTR);
|
2005-02-10 18:10:43 +01:00
|
|
|
|
2007-10-12 09:46:19 +02:00
|
|
|
/* ################ */
|
2004-10-05 20:31:58 +02:00
|
|
|
|
2010-10-01 13:37:34 +02:00
|
|
|
static const struct {
|
2005-06-14 19:21:18 +02:00
|
|
|
const char *url;
|
|
|
|
const char *path;
|
2012-09-24 13:05:13 +02:00
|
|
|
DWORD ret, todo;
|
2004-10-05 20:31:58 +02:00
|
|
|
} TEST_PATHFROMURL[] = {
|
2012-09-24 13:05:13 +02:00
|
|
|
/* 0 leading slash */
|
|
|
|
{"file:c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:c|/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:cx|/foo/bar", "cx|\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:c:foo/bar", "c:foo\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file:c|foo/bar", "c:foo\\bar", S_OK, 0},
|
|
|
|
{"file:c:/foo%20ba%2fr", "c:\\foo ba/r", S_OK, 0},
|
|
|
|
{"file:foo%20ba%2fr", "foo ba/r", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file:foo/bar/", "foo\\bar\\", S_OK, 0},
|
|
|
|
|
|
|
|
/* 1 leading (back)slash */
|
|
|
|
{"file:/c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:\\c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:/c|/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:/cx|/foo/bar", "\\cx|\\foo\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file:/c:foo/bar", "c:foo\\bar", S_OK, 0},
|
|
|
|
{"file:/c|foo/bar", "c:foo\\bar", S_OK, 0},
|
|
|
|
{"file:/c:/foo%20ba%2fr", "c:\\foo ba/r", S_OK, 0},
|
|
|
|
{"file:/foo%20ba%2fr", "\\foo ba/r", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file:/foo/bar/", "\\foo\\bar\\", S_OK, 0},
|
|
|
|
|
|
|
|
/* 2 leading (back)slashes */
|
|
|
|
{"file://c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file://c:/d:/foo/bar", "c:\\d:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file://c|/d|/foo/bar", "c:\\d|\\foo\\bar", S_OK, 0},
|
|
|
|
{"file://cx|/foo/bar", "\\\\cx|\\foo\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file://c:foo/bar", "c:foo\\bar", S_OK, 0},
|
|
|
|
{"file://c|foo/bar", "c:foo\\bar", S_OK, 0},
|
|
|
|
{"file://c:/foo%20ba%2fr", "c:\\foo%20ba%2fr", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file://c%3a/foo/../bar", "\\\\c:\\foo\\..\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file://c%7c/foo/../bar", "\\\\c|\\foo\\..\\bar", S_OK, 0},
|
|
|
|
{"file://foo%20ba%2fr", "\\\\foo ba/r", S_OK, 0},
|
|
|
|
{"file://localhost/c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file://localhost/c:/foo%20ba%5Cr", "c:\\foo ba\\r", S_OK, 0},
|
|
|
|
{"file://LocalHost/c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:\\\\localhost\\c:\\foo\\bar", "c:\\foo\\bar", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file://incomplete", "\\\\incomplete", S_OK, 0},
|
|
|
|
|
|
|
|
/* 3 leading (back)slashes (omitting hostname) */
|
|
|
|
{"file:///c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"File:///c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:///c:/foo%20ba%2fr", "c:\\foo ba/r", S_OK, 0},
|
|
|
|
{"file:///foo%20ba%2fr", "\\foo ba/r", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file:///foo/bar/", "\\foo\\bar\\", S_OK, 0},
|
|
|
|
{"file:///localhost/c:/foo/bar", "\\localhost\\c:\\foo\\bar", S_OK, 0},
|
|
|
|
|
|
|
|
/* 4 leading (back)slashes */
|
|
|
|
{"file:////c:/foo/bar", "c:\\foo\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file:////c:/foo%20ba%2fr", "c:\\foo%20ba%2fr", S_OK, 0},
|
|
|
|
{"file:////foo%20ba%2fr", "\\\\foo%20ba%2fr", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
|
|
|
|
/* 5 and more leading (back)slashes */
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file://///c:/foo/bar", "\\\\c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file://///c:/foo%20ba%2fr", "\\\\c:\\foo ba/r", S_OK, 0},
|
|
|
|
{"file://///foo%20ba%2fr", "\\\\foo ba/r", S_OK, 0},
|
|
|
|
{"file://////c:/foo/bar", "\\\\c:\\foo\\bar", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
|
|
|
|
/* Leading (back)slashes cannot be escaped */
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file:%2f%2flocalhost%2fc:/foo/bar", "//localhost/c:\\foo\\bar", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file:%5C%5Clocalhost%5Cc:/foo/bar", "\\\\localhost\\c:\\foo\\bar", S_OK, 0},
|
|
|
|
|
|
|
|
/* Hostname handling */
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file://l%6fcalhost/c:/foo/bar", "\\\\localhostc:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file://localhost:80/c:/foo/bar", "\\\\localhost:80c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file://host/c:/foo/bar", "\\\\hostc:\\foo\\bar", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file://host//c:/foo/bar", "\\\\host\\\\c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file://host/\\c:/foo/bar", "\\\\host\\\\c:\\foo\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file://host/c:foo/bar", "\\\\hostc:foo\\bar", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file://host/foo/bar", "\\\\host\\foo\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file:\\\\host\\c:\\foo\\bar", "\\\\hostc:\\foo\\bar", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file:\\\\host\\ca\\foo\\bar", "\\\\host\\ca\\foo\\bar", S_OK, 0},
|
2012-09-26 04:22:00 +02:00
|
|
|
{"file:\\\\host\\c|\\foo\\bar", "\\\\hostc|\\foo\\bar", S_OK, 0},
|
2012-09-24 13:05:13 +02:00
|
|
|
{"file:\\%5Chost\\c:\\foo\\bar", "\\\\host\\c:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:\\\\host\\cx:\\foo\\bar", "\\\\host\\cx:\\foo\\bar", S_OK, 0},
|
|
|
|
{"file:///host/c:/foo/bar", "\\host\\c:\\foo\\bar", S_OK, 0},
|
|
|
|
|
|
|
|
/* Not file URLs */
|
|
|
|
{"c:\\foo\\bar", NULL, E_INVALIDARG, 0},
|
|
|
|
{"foo/bar", NULL, E_INVALIDARG, 0},
|
|
|
|
{"http://foo/bar", NULL, E_INVALIDARG, 0},
|
2004-10-05 20:31:58 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-10-12 09:46:19 +02:00
|
|
|
static struct {
|
2005-06-14 19:21:18 +02:00
|
|
|
const char *path;
|
2004-10-05 20:31:58 +02:00
|
|
|
BOOL expect;
|
|
|
|
} TEST_PATH_IS_URL[] = {
|
|
|
|
{"http://foo/bar", TRUE},
|
|
|
|
{"c:\\foo\\bar", FALSE},
|
2008-02-27 18:56:16 +01:00
|
|
|
{"c:/foo/bar", FALSE},
|
2004-10-05 20:31:58 +02:00
|
|
|
{"foo://foo/bar", TRUE},
|
2005-01-03 18:08:40 +01:00
|
|
|
{"foo\\bar", FALSE},
|
2005-03-21 11:54:35 +01:00
|
|
|
{"foo.bar", FALSE},
|
|
|
|
{"bogusscheme:", TRUE},
|
2008-02-27 18:56:16 +01:00
|
|
|
{"http:partial", TRUE},
|
2008-11-09 19:19:51 +01:00
|
|
|
{"www.winehq.org", FALSE},
|
|
|
|
/* More examples that the user might enter as the browser start page */
|
|
|
|
{"winehq.org", FALSE},
|
|
|
|
{"ftp.winehq.org", FALSE},
|
|
|
|
{"http://winehq.org", TRUE},
|
|
|
|
{"http://www.winehq.org", TRUE},
|
|
|
|
{"https://winehq.org", TRUE},
|
|
|
|
{"https://www.winehq.org", TRUE},
|
|
|
|
{"ftp://winehq.org", TRUE},
|
|
|
|
{"ftp://ftp.winehq.org", TRUE},
|
|
|
|
{"file://does_not_exist.txt", TRUE},
|
|
|
|
{"about:blank", TRUE},
|
|
|
|
{"about:home", TRUE},
|
|
|
|
{"about:mozilla", TRUE},
|
|
|
|
/* scheme is case independent */
|
|
|
|
{"HTTP://www.winehq.org", TRUE},
|
|
|
|
/* a space at the start is not allowed */
|
|
|
|
{" http://www.winehq.org", FALSE},
|
|
|
|
{"", FALSE},
|
|
|
|
{NULL, FALSE}
|
2004-10-05 20:31:58 +02:00
|
|
|
};
|
|
|
|
|
2010-10-01 13:37:34 +02:00
|
|
|
static const struct {
|
2006-08-09 15:46:20 +02:00
|
|
|
const char *path;
|
|
|
|
const char *result;
|
|
|
|
} TEST_PATH_UNQUOTE_SPACES[] = {
|
|
|
|
{ "abcdef", "abcdef" },
|
|
|
|
{ "\"abcdef\"", "abcdef" },
|
|
|
|
{ "\"abcdef", "\"abcdef" },
|
|
|
|
{ "abcdef\"", "abcdef\"" },
|
|
|
|
{ "\"\"abcdef\"\"", "\"abcdef\"" },
|
|
|
|
{ "abc\"def", "abc\"def" },
|
|
|
|
{ "\"abc\"def", "\"abc\"def" },
|
|
|
|
{ "\"abc\"def\"", "abc\"def" },
|
|
|
|
{ "\'abcdef\'", "\'abcdef\'" },
|
|
|
|
{ "\"\"", "" },
|
|
|
|
{ "\"", "" }
|
|
|
|
};
|
2005-03-21 11:54:35 +01:00
|
|
|
|
2007-10-12 09:46:19 +02:00
|
|
|
/* ################ */
|
|
|
|
|
2015-04-11 11:05:25 +02:00
|
|
|
static LPWSTR GetWideString(const char *src)
|
2003-01-09 01:50:17 +01:00
|
|
|
{
|
2015-04-11 11:05:25 +02:00
|
|
|
WCHAR *ret;
|
2003-01-09 01:50:17 +01:00
|
|
|
|
2015-04-11 11:05:25 +02:00
|
|
|
if (!src)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, (2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, src, -1, ret, INTERNET_MAX_URL_LENGTH);
|
|
|
|
|
|
|
|
return ret;
|
2003-01-09 01:50:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void FreeWideString(LPWSTR wszString)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, wszString);
|
|
|
|
}
|
|
|
|
|
2006-08-09 15:46:20 +02:00
|
|
|
static LPSTR strdupA(LPCSTR p)
|
|
|
|
{
|
|
|
|
LPSTR ret;
|
|
|
|
DWORD len = (strlen(p) + 1);
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
memcpy(ret, p, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-10-12 09:46:19 +02:00
|
|
|
/* ################ */
|
2004-10-05 20:31:58 +02:00
|
|
|
|
2004-09-25 02:29:47 +02:00
|
|
|
static void test_PathSearchAndQualify(void)
|
|
|
|
{
|
|
|
|
WCHAR path1[] = {'c',':','\\','f','o','o',0};
|
|
|
|
WCHAR expect1[] = {'c',':','\\','f','o','o',0};
|
|
|
|
WCHAR path2[] = {'c',':','f','o','o',0};
|
|
|
|
WCHAR c_drive[] = {'c',':',0};
|
|
|
|
WCHAR foo[] = {'f','o','o',0};
|
|
|
|
WCHAR path3[] = {'\\','f','o','o',0};
|
|
|
|
WCHAR winini[] = {'w','i','n','.','i','n','i',0};
|
|
|
|
WCHAR out[MAX_PATH];
|
|
|
|
WCHAR cur_dir[MAX_PATH];
|
|
|
|
WCHAR dot[] = {'.',0};
|
|
|
|
|
|
|
|
/* c:\foo */
|
|
|
|
ok(PathSearchAndQualifyW(path1, out, MAX_PATH) != 0,
|
|
|
|
"PathSearchAndQualify rets 0\n");
|
|
|
|
ok(!lstrcmpiW(out, expect1), "strings don't match\n");
|
|
|
|
|
|
|
|
/* c:foo */
|
|
|
|
ok(PathSearchAndQualifyW(path2, out, MAX_PATH) != 0,
|
|
|
|
"PathSearchAndQualify rets 0\n");
|
|
|
|
GetFullPathNameW(c_drive, MAX_PATH, cur_dir, NULL);
|
|
|
|
PathAddBackslashW(cur_dir);
|
2006-05-24 18:05:09 +02:00
|
|
|
lstrcatW(cur_dir, foo);
|
2004-09-25 02:29:47 +02:00
|
|
|
ok(!lstrcmpiW(out, cur_dir), "strings don't match\n");
|
|
|
|
|
|
|
|
/* foo */
|
|
|
|
ok(PathSearchAndQualifyW(foo, out, MAX_PATH) != 0,
|
|
|
|
"PathSearchAndQualify rets 0\n");
|
|
|
|
GetFullPathNameW(dot, MAX_PATH, cur_dir, NULL);
|
|
|
|
PathAddBackslashW(cur_dir);
|
2006-05-24 18:05:09 +02:00
|
|
|
lstrcatW(cur_dir, foo);
|
2004-09-25 02:29:47 +02:00
|
|
|
ok(!lstrcmpiW(out, cur_dir), "strings don't match\n");
|
|
|
|
|
|
|
|
/* \foo */
|
|
|
|
ok(PathSearchAndQualifyW(path3, out, MAX_PATH) != 0,
|
|
|
|
"PathSearchAndQualify rets 0\n");
|
|
|
|
GetFullPathNameW(dot, MAX_PATH, cur_dir, NULL);
|
2006-05-24 18:05:09 +02:00
|
|
|
lstrcpyW(cur_dir + 2, path3);
|
2004-09-25 02:29:47 +02:00
|
|
|
ok(!lstrcmpiW(out, cur_dir), "strings don't match\n");
|
|
|
|
|
|
|
|
/* win.ini */
|
|
|
|
ok(PathSearchAndQualifyW(winini, out, MAX_PATH) != 0,
|
|
|
|
"PathSearchAndQualify rets 0\n");
|
|
|
|
if(!SearchPathW(NULL, winini, NULL, MAX_PATH, cur_dir, NULL))
|
|
|
|
GetFullPathNameW(winini, MAX_PATH, cur_dir, NULL);
|
|
|
|
ok(!lstrcmpiW(out, cur_dir), "strings don't match\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-10-05 20:31:58 +02:00
|
|
|
static void test_PathCreateFromUrl(void)
|
|
|
|
{
|
2005-03-14 11:09:53 +01:00
|
|
|
size_t i;
|
2004-10-05 20:31:58 +02:00
|
|
|
char ret_path[INTERNET_MAX_URL_LENGTH];
|
2012-09-25 16:32:57 +02:00
|
|
|
DWORD len, len2, ret;
|
2004-10-05 20:31:58 +02:00
|
|
|
WCHAR ret_pathW[INTERNET_MAX_URL_LENGTH];
|
|
|
|
WCHAR *pathW, *urlW;
|
2006-09-17 15:56:05 +02:00
|
|
|
|
2010-01-30 22:59:01 +01:00
|
|
|
if (!pPathCreateFromUrlA) {
|
|
|
|
win_skip("PathCreateFromUrlA not found\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-25 16:32:57 +02:00
|
|
|
/* Won't say how much is needed without a buffer */
|
|
|
|
len = 0xdeca;
|
|
|
|
ret = pPathCreateFromUrlA("file://foo", NULL, &len, 0);
|
|
|
|
ok(ret == E_INVALIDARG, "got 0x%08x expected E_INVALIDARG\n", ret);
|
|
|
|
ok(len == 0xdeca, "got %x expected 0xdeca\n", len);
|
2004-10-05 20:31:58 +02:00
|
|
|
|
2012-09-25 16:32:57 +02:00
|
|
|
/* Test the decoding itself */
|
2018-06-26 22:44:25 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(TEST_PATHFROMURL); i++) {
|
2004-10-05 20:31:58 +02:00
|
|
|
len = INTERNET_MAX_URL_LENGTH;
|
2010-01-30 22:59:01 +01:00
|
|
|
ret = pPathCreateFromUrlA(TEST_PATHFROMURL[i].url, ret_path, &len, 0);
|
2016-02-19 23:12:24 +01:00
|
|
|
todo_wine_if (TEST_PATHFROMURL[i].todo & 0x1)
|
2012-09-24 13:05:13 +02:00
|
|
|
ok(ret == TEST_PATHFROMURL[i].ret, "ret %08x from url %s\n", ret, TEST_PATHFROMURL[i].url);
|
|
|
|
if(SUCCEEDED(ret) && TEST_PATHFROMURL[i].path) {
|
|
|
|
if(!(TEST_PATHFROMURL[i].todo & 0x2)) {
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpiA(ret_path, TEST_PATHFROMURL[i].path), "got %s expected %s from url %s\n", ret_path, TEST_PATHFROMURL[i].path, TEST_PATHFROMURL[i].url);
|
2012-09-24 13:05:13 +02:00
|
|
|
ok(len == strlen(ret_path), "ret len %d from url %s\n", len, TEST_PATHFROMURL[i].url);
|
|
|
|
} else todo_wine
|
|
|
|
/* Wrong string, don't bother checking the length */
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpiA(ret_path, TEST_PATHFROMURL[i].path), "got %s expected %s from url %s\n", ret_path, TEST_PATHFROMURL[i].path, TEST_PATHFROMURL[i].url);
|
2004-10-05 20:31:58 +02:00
|
|
|
}
|
2012-09-25 16:32:57 +02:00
|
|
|
|
2010-01-30 22:59:01 +01:00
|
|
|
if (pPathCreateFromUrlW) {
|
|
|
|
len = INTERNET_MAX_URL_LENGTH;
|
|
|
|
pathW = GetWideString(TEST_PATHFROMURL[i].path);
|
|
|
|
urlW = GetWideString(TEST_PATHFROMURL[i].url);
|
|
|
|
ret = pPathCreateFromUrlW(urlW, ret_pathW, &len, 0);
|
2012-09-24 13:04:26 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, ret_pathW, -1, ret_path, sizeof(ret_path),NULL,NULL);
|
2016-02-19 23:12:24 +01:00
|
|
|
todo_wine_if (TEST_PATHFROMURL[i].todo & 0x1)
|
2012-09-24 13:05:13 +02:00
|
|
|
ok(ret == TEST_PATHFROMURL[i].ret, "ret %08x from url L\"%s\"\n", ret, TEST_PATHFROMURL[i].url);
|
|
|
|
if(SUCCEEDED(ret) && TEST_PATHFROMURL[i].path) {
|
|
|
|
if(!(TEST_PATHFROMURL[i].todo & 0x2)) {
|
|
|
|
ok(!lstrcmpiW(ret_pathW, pathW), "got %s expected %s from url L\"%s\"\n",
|
|
|
|
ret_path, TEST_PATHFROMURL[i].path, TEST_PATHFROMURL[i].url);
|
|
|
|
ok(len == lstrlenW(ret_pathW), "ret len %d from url L\"%s\"\n", len, TEST_PATHFROMURL[i].url);
|
|
|
|
} else todo_wine
|
2012-09-26 04:22:00 +02:00
|
|
|
/* Wrong string, don't bother checking the length */
|
2012-09-24 13:05:13 +02:00
|
|
|
ok(!lstrcmpiW(ret_pathW, pathW), "got %s expected %s from url L\"%s\"\n",
|
|
|
|
ret_path, TEST_PATHFROMURL[i].path, TEST_PATHFROMURL[i].url);
|
2010-01-30 22:59:01 +01:00
|
|
|
}
|
2012-09-25 16:32:57 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
/* Check what happens if the buffer is too small */
|
|
|
|
len2 = 2;
|
|
|
|
ret = pPathCreateFromUrlW(urlW, ret_pathW, &len2, 0);
|
|
|
|
ok(ret == E_POINTER, "ret %08x, expected E_POINTER from url %s\n", ret, TEST_PATHFROMURL[i].url);
|
2016-02-19 23:12:24 +01:00
|
|
|
todo_wine_if (TEST_PATHFROMURL[i].todo & 0x4)
|
2012-09-25 16:32:57 +02:00
|
|
|
ok(len2 == len + 1, "got len = %d expected %d from url %s\n", len2, len + 1, TEST_PATHFROMURL[i].url);
|
|
|
|
}
|
|
|
|
|
2010-01-30 22:59:01 +01:00
|
|
|
FreeWideString(urlW);
|
|
|
|
FreeWideString(pathW);
|
2004-10-05 20:31:58 +02:00
|
|
|
}
|
|
|
|
}
|
2012-10-01 03:29:55 +02:00
|
|
|
|
|
|
|
if (pPathCreateFromUrlAlloc)
|
|
|
|
{
|
|
|
|
static const WCHAR fileW[] = {'f','i','l','e',':','/','/','f','o','o',0};
|
|
|
|
static const WCHAR fooW[] = {'\\','\\','f','o','o',0};
|
|
|
|
|
|
|
|
pathW = NULL;
|
|
|
|
ret = pPathCreateFromUrlAlloc(fileW, &pathW, 0);
|
|
|
|
ok(ret == S_OK, "got 0x%08x expected S_OK\n", ret);
|
|
|
|
ok(lstrcmpiW(pathW, fooW) == 0, "got %s expected %s\n", wine_dbgstr_w(pathW), wine_dbgstr_w(fooW));
|
|
|
|
HeapFree(GetProcessHeap(), 0, pathW);
|
|
|
|
}
|
2004-10-05 20:31:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_PathIsUrl(void)
|
|
|
|
{
|
2005-03-14 11:09:53 +01:00
|
|
|
size_t i;
|
2004-10-05 20:31:58 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2018-06-26 22:44:25 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(TEST_PATH_IS_URL); i++) {
|
2004-10-05 20:31:58 +02:00
|
|
|
ret = PathIsURLA(TEST_PATH_IS_URL[i].path);
|
|
|
|
ok(ret == TEST_PATH_IS_URL[i].expect,
|
|
|
|
"returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
|
|
|
|
TEST_PATH_IS_URL[i].expect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-03 14:34:05 +01:00
|
|
|
static const DWORD SHELL_charclass[] =
|
|
|
|
{
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000080, 0x00000100, 0x00000200, 0x00000100,
|
|
|
|
0x00000100, 0x00000100, 0x00000100, 0x00000100,
|
|
|
|
0x00000100, 0x00000100, 0x00000002, 0x00000100,
|
|
|
|
0x00000040, 0x00000100, 0x00000004, 0x00000000,
|
|
|
|
0x00000100, 0x00000100, 0x00000100, 0x00000100,
|
|
|
|
0x00000100, 0x00000100, 0x00000100, 0x00000100,
|
|
|
|
0x00000100, 0x00000100, 0x00000010, 0x00000020,
|
|
|
|
0x00000000, 0x00000100, 0x00000000, 0x00000001,
|
|
|
|
0x00000100, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0x00000100,
|
|
|
|
0x00000008, 0x00000100, 0x00000100, 0x00000100,
|
|
|
|
0x00000100, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff, 0xffffffff, 0x00000100,
|
|
|
|
0x00000000, 0x00000100, 0x00000100
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_PathIsValidCharA(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
unsigned int c;
|
|
|
|
|
2010-03-03 10:38:39 +01:00
|
|
|
/* For whatever reason, PathIsValidCharA and PathAppendA share the same
|
|
|
|
* ordinal number in some native versions. Check this to prevent a crash.
|
|
|
|
*/
|
|
|
|
if (!pPathIsValidCharA || pPathIsValidCharA == (void*)pPathAppendA)
|
|
|
|
{
|
|
|
|
win_skip("PathIsValidCharA isn't available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-03 14:34:05 +01:00
|
|
|
for (c = 0; c < 0x7f; c++)
|
|
|
|
{
|
2005-02-10 18:10:43 +01:00
|
|
|
ret = pPathIsValidCharA( c, ~0U );
|
2008-09-28 21:34:28 +02:00
|
|
|
ok ( ret || !SHELL_charclass[c], "PathIsValidCharA failed: 0x%02x got 0x%08x\n", c, ret );
|
2005-02-03 14:34:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (c = 0x7f; c <= 0xff; c++)
|
|
|
|
{
|
2005-02-10 18:10:43 +01:00
|
|
|
ret = pPathIsValidCharA( c, ~0U );
|
2008-09-28 21:34:28 +02:00
|
|
|
ok ( ret, "PathIsValidCharA failed: 0x%02x got 0x%08x\n", c, ret );
|
2005-02-03 14:34:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_PathIsValidCharW(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
2008-09-28 21:34:28 +02:00
|
|
|
unsigned int c;
|
2005-02-03 14:34:05 +01:00
|
|
|
|
2010-03-03 10:38:39 +01:00
|
|
|
if (!pPathIsValidCharW)
|
|
|
|
{
|
|
|
|
win_skip("PathIsValidCharW isn't available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-03 14:34:05 +01:00
|
|
|
for (c = 0; c < 0x7f; c++)
|
|
|
|
{
|
2005-02-10 18:10:43 +01:00
|
|
|
ret = pPathIsValidCharW( c, ~0U );
|
2008-09-28 21:34:28 +02:00
|
|
|
ok ( ret || !SHELL_charclass[c], "PathIsValidCharW failed: 0x%02x got 0x%08x\n", c, ret );
|
2005-02-03 14:34:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (c = 0x007f; c <= 0xffff; c++)
|
|
|
|
{
|
2005-02-10 18:10:43 +01:00
|
|
|
ret = pPathIsValidCharW( c, ~0U );
|
2008-09-28 21:34:28 +02:00
|
|
|
ok ( ret, "PathIsValidCharW failed: 0x%02x got 0x%08x\n", c, ret );
|
2005-02-03 14:34:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-14 11:09:53 +01:00
|
|
|
static void test_PathMakePretty(void)
|
|
|
|
{
|
|
|
|
char buff[MAX_PATH];
|
|
|
|
|
|
|
|
ok (PathMakePrettyA(NULL) == FALSE, "PathMakePretty: NULL path succeeded\n");
|
|
|
|
buff[0] = '\0';
|
|
|
|
ok (PathMakePrettyA(buff) == TRUE, "PathMakePretty: Empty path failed\n");
|
|
|
|
|
|
|
|
strcpy(buff, "C:\\A LONG FILE NAME WITH \\SPACES.TXT");
|
|
|
|
ok (PathMakePrettyA(buff) == TRUE, "PathMakePretty: Long UC name failed\n");
|
|
|
|
ok (strcmp(buff, "C:\\a long file name with \\spaces.txt") == 0,
|
|
|
|
"PathMakePretty: Long UC name not changed\n");
|
|
|
|
|
|
|
|
strcpy(buff, "C:\\A LONG FILE NAME WITH \\MixedCase.TXT");
|
|
|
|
ok (PathMakePrettyA(buff) == FALSE, "PathMakePretty: Long MC name succeeded\n");
|
|
|
|
ok (strcmp(buff, "C:\\A LONG FILE NAME WITH \\MixedCase.TXT") == 0,
|
|
|
|
"PathMakePretty: Failed but modified path\n");
|
|
|
|
|
|
|
|
strcpy(buff, "TEST");
|
|
|
|
ok (PathMakePrettyA(buff) == TRUE, "PathMakePretty: Short name failed\n");
|
|
|
|
ok (strcmp(buff, "Test") == 0, "PathMakePretty: 1st char lowercased %s\n", buff);
|
|
|
|
}
|
|
|
|
|
2006-04-11 20:55:25 +02:00
|
|
|
static void test_PathMatchSpec(void)
|
|
|
|
{
|
|
|
|
static const char file[] = "c:\\foo\\bar\\filename.ext";
|
|
|
|
static const char spec1[] = ".ext";
|
|
|
|
static const char spec2[] = "*.ext";
|
|
|
|
static const char spec3[] = "*.ext ";
|
|
|
|
static const char spec4[] = " *.ext";
|
|
|
|
static const char spec5[] = "* .ext";
|
|
|
|
static const char spec6[] = "*. ext";
|
|
|
|
static const char spec7[] = "* . ext";
|
|
|
|
static const char spec8[] = "*.e?t";
|
|
|
|
static const char spec9[] = "filename.ext";
|
|
|
|
static const char spec10[] = "*bar\\filename.ext";
|
|
|
|
static const char spec11[] = " foo; *.ext";
|
|
|
|
static const char spec12[] = "*.ext;*.bar";
|
|
|
|
static const char spec13[] = "*bar*";
|
|
|
|
|
|
|
|
ok (PathMatchSpecA(file, spec1) == FALSE, "PathMatchSpec: Spec1 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec2) == TRUE, "PathMatchSpec: Spec2 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec3) == FALSE, "PathMatchSpec: Spec3 failed\n");
|
2006-04-11 21:17:52 +02:00
|
|
|
ok (PathMatchSpecA(file, spec4) == TRUE, "PathMatchSpec: Spec4 failed\n");
|
2006-04-11 20:55:25 +02:00
|
|
|
todo_wine ok (PathMatchSpecA(file, spec5) == TRUE, "PathMatchSpec: Spec5 failed\n");
|
|
|
|
todo_wine ok (PathMatchSpecA(file, spec6) == TRUE, "PathMatchSpec: Spec6 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec7) == FALSE, "PathMatchSpec: Spec7 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec8) == TRUE, "PathMatchSpec: Spec8 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec9) == FALSE, "PathMatchSpec: Spec9 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec10) == TRUE, "PathMatchSpec: Spec10 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec11) == TRUE, "PathMatchSpec: Spec11 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec12) == TRUE, "PathMatchSpec: Spec12 failed\n");
|
|
|
|
ok (PathMatchSpecA(file, spec13) == TRUE, "PathMatchSpec: Spec13 failed\n");
|
|
|
|
}
|
|
|
|
|
2006-06-26 23:37:45 +02:00
|
|
|
static void test_PathCombineW(void)
|
2006-06-23 15:21:02 +02:00
|
|
|
{
|
|
|
|
LPWSTR wszString, wszString2;
|
2007-04-05 23:14:42 +02:00
|
|
|
WCHAR wbuf[MAX_PATH+1], wstr1[MAX_PATH] = {'C',':','\\',0}, wstr2[MAX_PATH];
|
|
|
|
static const WCHAR expout[] = {'C',':','\\','A','A',0};
|
|
|
|
int i;
|
2010-03-03 10:38:39 +01:00
|
|
|
|
|
|
|
if (!pPathCombineW)
|
|
|
|
{
|
|
|
|
win_skip("PathCombineW isn't available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-06-23 15:21:02 +02:00
|
|
|
wszString2 = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
|
|
|
|
|
|
|
|
/* NULL test */
|
2006-06-26 23:37:45 +02:00
|
|
|
wszString = pPathCombineW(NULL, NULL, NULL);
|
|
|
|
ok (wszString == NULL, "Expected a NULL return\n");
|
2006-06-23 15:21:02 +02:00
|
|
|
|
2006-06-26 23:37:45 +02:00
|
|
|
/* Some NULL */
|
2007-04-05 23:14:42 +02:00
|
|
|
wszString2[0] = 'a';
|
2006-06-26 23:37:45 +02:00
|
|
|
wszString = pPathCombineW(wszString2, NULL, NULL);
|
2009-02-25 14:04:57 +01:00
|
|
|
ok (wszString == NULL ||
|
2009-03-03 21:42:32 +01:00
|
|
|
broken(wszString[0] == 'a'), /* Win95 and some W2K */
|
2009-02-25 14:04:57 +01:00
|
|
|
"Expected a NULL return\n");
|
|
|
|
ok (wszString2[0] == 0 ||
|
2009-03-03 21:42:32 +01:00
|
|
|
broken(wszString2[0] == 'a'), /* Win95 and some W2K */
|
2009-02-25 14:04:57 +01:00
|
|
|
"Destination string not empty\n");
|
2007-04-05 23:14:42 +02:00
|
|
|
|
2006-06-26 23:37:45 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, wszString2);
|
2007-04-05 23:14:42 +02:00
|
|
|
|
|
|
|
/* overflow test */
|
|
|
|
wstr2[0] = wstr2[1] = wstr2[2] = 'A';
|
|
|
|
for (i=3; i<MAX_PATH/2; i++)
|
|
|
|
wstr1[i] = wstr2[i] = 'A';
|
|
|
|
wstr1[(MAX_PATH/2) - 1] = wstr2[MAX_PATH/2] = 0;
|
|
|
|
memset(wbuf, 0xbf, sizeof(wbuf));
|
|
|
|
|
|
|
|
wszString = pPathCombineW(wbuf, wstr1, wstr2);
|
|
|
|
ok(wszString == NULL, "Expected a NULL return\n");
|
2009-02-26 13:48:52 +01:00
|
|
|
ok(wbuf[0] == 0 ||
|
2009-03-03 21:42:32 +01:00
|
|
|
broken(wbuf[0] == 0xbfbf), /* Win95 and some W2K */
|
2009-02-26 13:48:52 +01:00
|
|
|
"Buffer contains data\n");
|
2007-04-05 23:14:42 +02:00
|
|
|
|
|
|
|
/* PathCombineW can be used in place */
|
|
|
|
wstr1[3] = 0;
|
|
|
|
wstr2[2] = 0;
|
|
|
|
ok(PathCombineW(wstr1, wstr1, wstr2) == wstr1, "Expected a wstr1 return\n");
|
|
|
|
ok(StrCmpW(wstr1, expout) == 0, "Unexpected PathCombine output\n");
|
2006-06-26 23:37:45 +02:00
|
|
|
}
|
|
|
|
|
2007-04-05 23:14:42 +02:00
|
|
|
|
2006-06-26 23:37:45 +02:00
|
|
|
#define LONG_LEN (MAX_PATH * 2)
|
|
|
|
#define HALF_LEN (MAX_PATH / 2 + 1)
|
|
|
|
|
|
|
|
static void test_PathCombineA(void)
|
|
|
|
{
|
|
|
|
LPSTR str;
|
|
|
|
char dest[MAX_PATH];
|
|
|
|
char too_long[LONG_LEN];
|
|
|
|
char one[HALF_LEN], two[HALF_LEN];
|
|
|
|
|
|
|
|
/* try NULL dest */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathCombineA(NULL, "C:\\", "one\\two\\three");
|
|
|
|
ok(str == NULL, "Expected NULL, got %p\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try NULL dest and NULL directory */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathCombineA(NULL, NULL, "one\\two\\three");
|
|
|
|
ok(str == NULL, "Expected NULL, got %p\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try all NULL*/
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathCombineA(NULL, NULL, NULL);
|
|
|
|
ok(str == NULL, "Expected NULL, got %p\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try NULL file part */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", NULL);
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\"), "Expected C:\\, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try empty file part */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", "");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\"), "Expected C:\\, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try empty directory and file part */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "", "");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "\\") ||
|
|
|
|
broken(!lstrcmpA(str, "control")), /* Win95 and some W2K */
|
2009-02-26 13:48:52 +01:00
|
|
|
"Expected \\, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try NULL directory */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, NULL, "one\\two\\three");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "one\\two\\three"), "Expected one\\two\\three, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try NULL directory and empty file part */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, NULL, "");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "\\") ||
|
|
|
|
broken(!lstrcmpA(str, "one\\two\\three")), /* Win95 and some W2K */
|
2009-02-26 13:48:52 +01:00
|
|
|
"Expected \\, got %s\n", str);
|
|
|
|
ok(GetLastError() == 0xdeadbeef ||
|
|
|
|
broken(GetLastError() == ERROR_INVALID_PARAMETER), /* Win95 */
|
|
|
|
"Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try NULL directory and file part */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, NULL, NULL);
|
2009-02-26 13:48:52 +01:00
|
|
|
ok(str == NULL ||
|
|
|
|
broken(str != NULL), /* Win95 and some W2K */
|
|
|
|
"Expected str == NULL, got %p\n", str);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!dest[0] || broken(!lstrcmpA(dest, "control")), /* Win95 and some W2K */
|
2009-02-25 14:04:57 +01:00
|
|
|
"Expected 0 length, got %i\n", lstrlenA(dest));
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try directory without backslash */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:", "one\\two\\three");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try directory with backslash */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", "one\\two\\three");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try directory with backslash and file with prepended backslash */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", "\\one\\two\\three");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try previous test, with backslash appended as well */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", "\\one\\two\\three\\");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try a relative directory */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "relative\\dir", "\\one\\two\\three\\");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2008-06-24 19:01:33 +02:00
|
|
|
/* Vista fails which probably makes sense as PathCombineA expects an absolute dir */
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "one\\two\\three\\"), "Expected one\\two\\three\\, got %s\n", str);
|
2008-06-24 19:01:33 +02:00
|
|
|
}
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try forward slashes */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", "one/two/three\\");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\one/two/three\\"), "Expected one/two/three\\, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try a really weird directory */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\/\\/", "\\one\\two\\three\\");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try periods */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", "one\\..\\two\\.\\three");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\two\\three"), "Expected C:\\two\\three, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
/* try .. as file */
|
|
|
|
/* try forward slashes */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", "..");
|
|
|
|
ok(str == dest, "Expected str == dest, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(str, "C:\\"), "Expected C:\\, got %s\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:37:45 +02:00
|
|
|
|
|
|
|
memset(too_long, 'a', LONG_LEN);
|
|
|
|
too_long[LONG_LEN - 1] = '\0';
|
|
|
|
|
|
|
|
/* try a file longer than MAX_PATH */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, "C:\\", too_long);
|
2007-04-05 23:14:42 +02:00
|
|
|
ok(str == NULL, "Expected str == NULL, got %p\n", str);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!dest[0] || broken(!lstrcmpA(dest, "control")), /* Win95 and some W2K */
|
2009-02-25 14:04:57 +01:00
|
|
|
"Expected 0 length, got %i\n", lstrlenA(dest));
|
2007-04-05 23:14:42 +02:00
|
|
|
todo_wine ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-23 15:21:02 +02:00
|
|
|
|
2006-06-26 23:37:45 +02:00
|
|
|
/* try a directory longer than MAX_PATH */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, too_long, "one\\two\\three");
|
2007-04-05 23:14:42 +02:00
|
|
|
ok(str == NULL, "Expected str == NULL, got %p\n", str);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!dest[0] || broken(!lstrcmpA(dest, "control")), /* Win95 and some W2K */
|
2009-02-25 14:04:57 +01:00
|
|
|
"Expected 0 length, got %i\n", lstrlenA(dest));
|
2007-04-05 23:14:42 +02:00
|
|
|
todo_wine ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-23 15:21:02 +02:00
|
|
|
|
2006-06-26 23:37:45 +02:00
|
|
|
memset(one, 'b', HALF_LEN);
|
|
|
|
memset(two, 'c', HALF_LEN);
|
|
|
|
one[HALF_LEN - 1] = '\0';
|
|
|
|
two[HALF_LEN - 1] = '\0';
|
|
|
|
|
|
|
|
/* destination string is longer than MAX_PATH, but not the constituent parts */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyA(dest, "control");
|
|
|
|
str = PathCombineA(dest, one, two);
|
2007-04-05 23:14:42 +02:00
|
|
|
ok(str == NULL, "Expected str == NULL, got %p\n", str);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!dest[0] || broken(!lstrcmpA(dest, "control")), /* Win95 and some W2K */
|
2009-02-25 14:04:57 +01:00
|
|
|
"Expected 0 length, got %i\n", lstrlenA(dest));
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-23 15:21:02 +02:00
|
|
|
}
|
2006-04-11 20:55:25 +02:00
|
|
|
|
2006-06-26 23:41:22 +02:00
|
|
|
static void test_PathAddBackslash(void)
|
|
|
|
{
|
|
|
|
LPSTR str;
|
|
|
|
char path[MAX_PATH];
|
|
|
|
char too_long[LONG_LEN];
|
|
|
|
|
|
|
|
/* try a NULL path */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathAddBackslashA(NULL);
|
|
|
|
ok(str == NULL, "Expected str == NULL, got %p\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:41:22 +02:00
|
|
|
|
|
|
|
/* try an empty path */
|
|
|
|
path[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathAddBackslashA(path);
|
|
|
|
ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!path[0], "Expected empty string, got %i\n", lstrlenA(path));
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:41:22 +02:00
|
|
|
|
|
|
|
/* try a relative path */
|
|
|
|
lstrcpyA(path, "one\\two");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathAddBackslashA(path);
|
|
|
|
ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "one\\two\\"), "Expected one\\two\\, got %s\n", path);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:41:22 +02:00
|
|
|
|
|
|
|
/* try periods */
|
|
|
|
lstrcpyA(path, "one\\..\\two");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathAddBackslashA(path);
|
|
|
|
ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "one\\..\\two\\"), "Expected one\\..\\two\\, got %s\n", path);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:41:22 +02:00
|
|
|
|
|
|
|
/* try just a space */
|
|
|
|
lstrcpyA(path, " ");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathAddBackslashA(path);
|
|
|
|
ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, " \\"), "Expected \\, got %s\n", path);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:41:22 +02:00
|
|
|
|
|
|
|
/* path already has backslash */
|
|
|
|
lstrcpyA(path, "C:\\one\\");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathAddBackslashA(path);
|
|
|
|
ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C:\\one\\"), "Expected C:\\one\\, got %s\n", path);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:41:22 +02:00
|
|
|
|
|
|
|
memset(too_long, 'a', LONG_LEN);
|
|
|
|
too_long[LONG_LEN - 1] = '\0';
|
|
|
|
|
|
|
|
/* path is longer than MAX_PATH */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
str = PathAddBackslashA(too_long);
|
|
|
|
ok(str == NULL, "Expected str == NULL, got %p\n", str);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-26 23:41:22 +02:00
|
|
|
}
|
|
|
|
|
2006-06-27 22:05:30 +02:00
|
|
|
static void test_PathAppendA(void)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
char too_long[LONG_LEN];
|
2009-08-24 14:25:40 +02:00
|
|
|
char half[HALF_LEN];
|
2006-06-27 22:05:30 +02:00
|
|
|
BOOL res;
|
|
|
|
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "C:\\one");
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try NULL pszMore */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, NULL);
|
|
|
|
ok(!res, "Expected failure\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C:\\one"), "Expected C:\\one, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try empty pszMore */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, "");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C:\\one"), "Expected C:\\one, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try NULL pszPath */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(NULL, "two\\three");
|
|
|
|
ok(!res, "Expected failure\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try empty pszPath */
|
|
|
|
path[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, "two\\three");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "two\\three"), "Expected \\two\\three, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try empty pszPath and empty pszMore */
|
|
|
|
path[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, "");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "\\"), "Expected \\, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try legit params */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "C:\\one");
|
2006-06-27 22:05:30 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, "two\\three");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try pszPath with backslash after it */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "C:\\one\\");
|
2006-06-27 22:05:30 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, "two\\three");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try pszMore with backslash before it */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "C:\\one");
|
2006-06-27 22:05:30 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, "\\two\\three");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try pszMore with backslash after it */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "C:\\one");
|
2006-06-27 22:05:30 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, "two\\three\\");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try spaces in pszPath */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "C: \\ one ");
|
2006-06-27 22:05:30 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, "two\\three");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C: \\ one \\two\\three"), "Expected C: \\ one \\two\\three, got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* try spaces in pszMore */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "C:\\one");
|
2006-06-27 22:05:30 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, " two \\ three ");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "C:\\one\\ two \\ three "), "Expected 'C:\\one\\ two \\ three ', got %s\n", path);
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* pszPath is too long */
|
|
|
|
memset(too_long, 'a', LONG_LEN);
|
|
|
|
too_long[LONG_LEN - 1] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(too_long, "two\\three");
|
2007-04-05 23:14:42 +02:00
|
|
|
ok(!res, "Expected failure\n");
|
|
|
|
todo_wine ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!too_long[0] || broken(lstrlenA(too_long) == (LONG_LEN - 1)), /* Win95 and some W2K */
|
2013-10-15 21:41:10 +02:00
|
|
|
"Expected length of too_long to be zero, got %i\n", lstrlenA(too_long));
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* pszMore is too long */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "C:\\one");
|
2006-06-27 22:05:30 +02:00
|
|
|
memset(too_long, 'a', LONG_LEN);
|
|
|
|
too_long[LONG_LEN - 1] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathAppendA(path, too_long);
|
2007-04-05 23:14:42 +02:00
|
|
|
ok(!res, "Expected failure\n");
|
|
|
|
todo_wine ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!path[0] || broken(!lstrcmpA(path, "C:\\one")), /* Win95 and some W2K */
|
2013-10-15 21:41:10 +02:00
|
|
|
"Expected length of path to be zero, got %i\n", lstrlenA(path));
|
2006-06-27 22:05:30 +02:00
|
|
|
|
|
|
|
/* both params combined are too long */
|
2009-08-24 14:25:40 +02:00
|
|
|
memset(path, 'a', HALF_LEN);
|
|
|
|
path[HALF_LEN - 1] = '\0';
|
|
|
|
memset(half, 'b', HALF_LEN);
|
|
|
|
half[HALF_LEN - 1] = '\0';
|
2006-06-27 22:05:30 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2009-08-24 14:25:40 +02:00
|
|
|
res = PathAppendA(path, half);
|
2007-04-05 23:14:42 +02:00
|
|
|
ok(!res, "Expected failure\n");
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!path[0] || broken(lstrlenA(path) == (HALF_LEN - 1)), /* Win95 and some W2K */
|
2013-10-15 21:41:10 +02:00
|
|
|
"Expected length of path to be zero, got %i\n", lstrlenA(path));
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-27 22:05:30 +02:00
|
|
|
}
|
|
|
|
|
2006-06-29 22:33:05 +02:00
|
|
|
static void test_PathCanonicalizeA(void)
|
|
|
|
{
|
2008-07-27 22:21:22 +02:00
|
|
|
char dest[LONG_LEN + MAX_PATH];
|
2006-06-29 22:33:05 +02:00
|
|
|
char too_long[LONG_LEN];
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
/* try a NULL source */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, NULL);
|
|
|
|
ok(!res, "Expected failure\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
2006-10-06 12:43:34 +02:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(dest[0] == 0 || !lstrcmpA(dest, "test"),
|
2008-06-24 19:09:57 +02:00
|
|
|
"Expected either an empty string (Vista) or test, got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try an empty source */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "\\") ||
|
|
|
|
broken(!lstrcmpA(dest, "test")), /* Win95 and some W2K */
|
2009-02-26 13:48:52 +01:00
|
|
|
"Expected \\, got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try a NULL dest */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(NULL, "C:\\");
|
|
|
|
ok(!res, "Expected failure\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
2006-10-06 12:43:34 +02:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try empty dest */
|
|
|
|
dest[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "C:\\");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "C:\\"), "Expected C:\\, got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try non-empty dest */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "C:\\");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "C:\\"), "Expected C:\\, got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try a space for source */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, " ");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, " "), "Expected ' ', got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try a relative path */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "one\\two");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "one\\two"), "Expected one\\two, got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try current dir and previous dir */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "C:\\one\\.\\..\\two\\three\\..");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "C:\\two"), "Expected C:\\two, got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try simple forward slashes */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "C:\\one/two/three\\four/five\\six");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "C:\\one/two/three\\four/five\\six"),
|
2006-06-29 22:33:05 +02:00
|
|
|
"Expected C:\\one/two/three\\four/five\\six, got %s\n", dest);
|
|
|
|
|
|
|
|
/* try simple forward slashes with same dir */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "C:\\one/.\\two");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "C:\\one/.\\two"), "Expected C:\\one/.\\two, got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try simple forward slashes with change dir */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "C:\\one/.\\two\\..");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "C:\\one/.") ||
|
|
|
|
!lstrcmpA(dest, "C:\\one/"), /* Vista */
|
2008-09-02 08:09:59 +02:00
|
|
|
"Expected \"C:\\one/.\" or \"C:\\one/\", got \"%s\"\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try forward slashes with change dirs
|
|
|
|
* NOTE: if there is a forward slash in between two backslashes,
|
|
|
|
* everything in between the two backslashes is considered on dir
|
|
|
|
*/
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, "C:\\one/.\\..\\two/three\\..\\four/.five");
|
|
|
|
ok(res, "Expected success\n");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(dest, "C:\\four/.five"), "Expected C:\\four/.five, got %s\n", dest);
|
2006-06-29 22:33:05 +02:00
|
|
|
|
|
|
|
/* try src is too long */
|
|
|
|
memset(too_long, 'a', LONG_LEN);
|
|
|
|
too_long[LONG_LEN - 1] = '\0';
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(dest, "test");
|
2006-06-29 22:33:05 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = PathCanonicalizeA(dest, too_long);
|
2009-02-26 13:48:52 +01:00
|
|
|
ok(!res ||
|
|
|
|
broken(res), /* Win95, some W2K and XP-SP1 */
|
|
|
|
"Expected failure\n");
|
2006-06-29 22:33:05 +02:00
|
|
|
todo_wine
|
|
|
|
{
|
2008-08-26 15:52:35 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef || GetLastError() == ERROR_FILENAME_EXCED_RANGE /* Vista */,
|
|
|
|
"Expected 0xdeadbeef or ERROR_FILENAME_EXCED_RANGE, got %d\n", GetLastError());
|
2006-06-29 22:33:05 +02:00
|
|
|
}
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(lstrlenA(too_long) == LONG_LEN - 1, "Expected length LONG_LEN - 1, got %i\n", lstrlenA(too_long));
|
2006-06-29 22:33:05 +02:00
|
|
|
}
|
|
|
|
|
2006-06-29 22:33:18 +02:00
|
|
|
static void test_PathFindExtensionA(void)
|
|
|
|
{
|
|
|
|
LPSTR ext;
|
|
|
|
char path[MAX_PATH];
|
|
|
|
char too_long[LONG_LEN];
|
|
|
|
|
|
|
|
/* try a NULL path */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ext = PathFindExtensionA(NULL);
|
|
|
|
ok(ext == NULL, "Expected NULL, got %p\n", ext);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-29 22:33:18 +02:00
|
|
|
|
|
|
|
/* try an empty path */
|
|
|
|
path[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ext = PathFindExtensionA(path);
|
|
|
|
ok(ext == path, "Expected ext == path, got %p\n", ext);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!ext[0], "Expected length 0, got %i\n", lstrlenA(ext));
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-29 22:33:18 +02:00
|
|
|
|
|
|
|
/* try a path without an extension */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "file");
|
2006-06-29 22:33:18 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ext = PathFindExtensionA(path);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(ext == path + lstrlenA(path), "Expected ext == path, got %p\n", ext);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!ext[0], "Expected length 0, got %i\n", lstrlenA(ext));
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-29 22:33:18 +02:00
|
|
|
|
|
|
|
/* try a path with an extension */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "file.txt");
|
2006-06-29 22:33:18 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ext = PathFindExtensionA(path);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(ext == path + lstrlenA("file"),
|
|
|
|
"Expected ext == path + lstrlenA(\"file\"), got %p\n", ext);
|
|
|
|
ok(!lstrcmpA(ext, ".txt"), "Expected .txt, got %s\n", ext);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-29 22:33:18 +02:00
|
|
|
|
|
|
|
/* try a path with two extensions */
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "file.txt.doc");
|
2006-06-29 22:33:18 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ext = PathFindExtensionA(path);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(ext == path + lstrlenA("file.txt"),
|
|
|
|
"Expected ext == path + lstrlenA(\"file.txt\"), got %p\n", ext);
|
|
|
|
ok(!lstrcmpA(ext, ".doc"), "Expected .txt, got %s\n", ext);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-29 22:33:18 +02:00
|
|
|
|
|
|
|
/* try a path longer than MAX_PATH without an extension*/
|
|
|
|
memset(too_long, 'a', LONG_LEN);
|
|
|
|
too_long[LONG_LEN - 1] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ext = PathFindExtensionA(too_long);
|
|
|
|
ok(ext == too_long + LONG_LEN - 1, "Expected ext == too_long + LONG_LEN - 1, got %p\n", ext);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-29 22:33:18 +02:00
|
|
|
|
|
|
|
/* try a path longer than MAX_PATH with an extension*/
|
|
|
|
memset(too_long, 'a', LONG_LEN);
|
|
|
|
too_long[LONG_LEN - 1] = '\0';
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(too_long + 300, ".abcde");
|
|
|
|
too_long[lstrlenA(too_long)] = 'a';
|
2006-06-29 22:33:18 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ext = PathFindExtensionA(too_long);
|
|
|
|
ok(ext == too_long + 300, "Expected ext == too_long + 300, got %p\n", ext);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(lstrlenA(ext) == LONG_LEN - 301, "Expected LONG_LEN - 301, got %i\n", lstrlenA(ext));
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-06-29 22:33:18 +02:00
|
|
|
}
|
|
|
|
|
2006-07-13 02:18:37 +02:00
|
|
|
static void test_PathBuildRootA(void)
|
|
|
|
{
|
|
|
|
LPSTR root;
|
|
|
|
char path[10];
|
|
|
|
char root_expected[26][4];
|
|
|
|
char drive;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
/* set up the expected paths */
|
|
|
|
for (drive = 'A'; drive <= 'Z'; drive++)
|
|
|
|
sprintf(root_expected[drive - 'A'], "%c:\\", drive);
|
|
|
|
|
|
|
|
/* test the expected values */
|
|
|
|
for (j = 0; j < 26; j++)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "aaaaaaaaa");
|
2006-07-13 02:18:37 +02:00
|
|
|
root = PathBuildRootA(path, j);
|
|
|
|
ok(root == path, "Expected root == path, got %p\n", root);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(root, root_expected[j]), "Expected %s, got %s\n", root_expected[j], root);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:18:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test a negative drive number */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "aaaaaaaaa");
|
2006-07-13 02:18:37 +02:00
|
|
|
root = PathBuildRootA(path, -1);
|
|
|
|
ok(root == path, "Expected root == path, got %p\n", root);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!lstrcmpA(path, "aaaaaaaaa") || !path[0], /* Vista */
|
2008-09-02 08:09:59 +02:00
|
|
|
"Expected aaaaaaaaa or empty string, got %s\n", path);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:18:37 +02:00
|
|
|
|
|
|
|
/* test a drive number greater than 25 */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "aaaaaaaaa");
|
2006-07-13 02:18:37 +02:00
|
|
|
root = PathBuildRootA(path, 26);
|
|
|
|
ok(root == path, "Expected root == path, got %p\n", root);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!lstrcmpA(path, "aaaaaaaaa") || !path[0], /* Vista */
|
2008-09-02 08:09:59 +02:00
|
|
|
"Expected aaaaaaaaa or empty string, got %s\n", path);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:18:37 +02:00
|
|
|
|
|
|
|
/* length of path is less than 4 */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path, "aa");
|
2006-07-13 02:18:37 +02:00
|
|
|
root = PathBuildRootA(path, 0);
|
|
|
|
ok(root == path, "Expected root == path, got %p\n", root);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path, "A:\\"), "Expected A:\\, got %s\n", path);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:18:37 +02:00
|
|
|
|
|
|
|
/* path is NULL */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
root = PathBuildRootA(NULL, 0);
|
|
|
|
ok(root == NULL, "Expected root == NULL, got %p\n", root);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:18:37 +02:00
|
|
|
}
|
|
|
|
|
2006-07-13 02:19:55 +02:00
|
|
|
static void test_PathCommonPrefixA(void)
|
|
|
|
{
|
|
|
|
char path1[MAX_PATH], path2[MAX_PATH];
|
|
|
|
char out[MAX_PATH];
|
|
|
|
int count;
|
|
|
|
|
|
|
|
/* test NULL path1 */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path2, "C:\\");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(NULL, path2, out);
|
|
|
|
ok(count == 0, "Expected 0, got %i\n", count);
|
|
|
|
todo_wine
|
|
|
|
{
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(out, "aaa"), "Expected aaa, got %s\n", out);
|
2006-07-13 02:19:55 +02:00
|
|
|
}
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* test NULL path2 */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "C:\\");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, NULL, out);
|
|
|
|
ok(count == 0, "Expected 0, got %i\n", count);
|
|
|
|
todo_wine
|
|
|
|
{
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(out, "aaa"), "Expected aaa, got %s\n", out);
|
2006-07-13 02:19:55 +02:00
|
|
|
}
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* test empty path1 */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
path1[0] = '\0';
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path2, "C:\\");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 0, "Expected 0, got %i\n", count);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!out[0], "Expected 0 length out, got %i\n", lstrlenA(out));
|
|
|
|
ok(!path1[0], "Expected 0 length path1, got %i\n", lstrlenA(path1));
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* test empty path1 */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
path2[0] = '\0';
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "C:\\");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 0, "Expected 0, got %i\n", count);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!out[0], "Expected 0 length out, got %i\n", lstrlenA(out));
|
|
|
|
ok(!path2[0], "Expected 0 length path2, got %i\n", lstrlenA(path2));
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* paths are legit, out is NULL */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "C:\\");
|
|
|
|
lstrcpyA(path2, "C:\\");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, NULL);
|
|
|
|
ok(count == 3, "Expected 3, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* all parameters legit */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "C:\\");
|
|
|
|
lstrcpyA(path2, "C:\\");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 3, "Expected 3, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "C:\\"), "Expected C:\\, got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* path1 and path2 not the same, but common prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "C:\\one\\two");
|
|
|
|
lstrcpyA(path2, "C:\\one\\three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 6, "Expected 6, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "C:\\one\\two"), "Expected C:\\one\\two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "C:\\one\\three"), "Expected C:\\one\\three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "C:\\one"), "Expected C:\\one, got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try . prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\.two");
|
|
|
|
lstrcpyA(path2, "one\\.three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 3, "Expected 3, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\.two"), "Expected one\\.two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "one\\.three"), "Expected one\\.three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "one"), "Expected one, got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try .. prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\..two");
|
|
|
|
lstrcpyA(path2, "one\\..three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 3, "Expected 3, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\..two"), "Expected one\\..two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "one\\..three"), "Expected one\\..three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "one"), "Expected one, got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try ... prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\...two");
|
|
|
|
lstrcpyA(path2, "one\\...three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 3, "Expected 3, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\...two"), "Expected one\\...two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "one\\...three"), "Expected one\\...three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "one"), "Expected one, got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try .\ prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\.\\two");
|
|
|
|
lstrcpyA(path2, "one\\.\\three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 5, "Expected 5, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\.\\two"), "Expected one\\.\\two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "one\\.\\three"), "Expected one\\.\\three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "one\\."), "Expected one\\., got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try ..\ prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\..\\two");
|
|
|
|
lstrcpyA(path2, "one\\..\\three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 6, "Expected 6, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\..\\two"), "Expected one\\..\\two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "one\\..\\three"), "Expected one\\..\\three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "one\\.."), "Expected one\\.., got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try ...\\ prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\...\\two");
|
|
|
|
lstrcpyA(path2, "one\\...\\three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 7, "Expected 7, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\...\\two"), "Expected one\\...\\two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "one\\...\\three"), "Expected one\\...\\three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "one\\..."), "Expected one\\..., got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try prefix that is not an msdn labeled prefix type */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "same");
|
|
|
|
lstrcpyA(path2, "same");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 4, "Expected 4, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "same"), "Expected same, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "same"), "Expected same, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "same"), "Expected same, got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try . after directory */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\mid.\\two");
|
|
|
|
lstrcpyA(path2, "one\\mid.\\three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 8, "Expected 8, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\mid.\\two"), "Expected one\\mid.\\two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "one\\mid.\\three"), "Expected one\\mid.\\three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "one\\mid."), "Expected one\\mid., got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try . in the middle of a directory */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\mid.end\\two");
|
|
|
|
lstrcpyA(path2, "one\\mid.end\\three");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 11, "Expected 11, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\mid.end\\two"), "Expected one\\mid.end\\two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "one\\mid.end\\three"), "Expected one\\mid.end\\three, got %s\n", path2);
|
|
|
|
ok(!lstrcmpA(out, "one\\mid.end"), "Expected one\\mid.end, got %s\n", out);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
|
|
|
|
/* try comparing a .. with the expanded path */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-15 21:41:10 +02:00
|
|
|
lstrcpyA(path1, "one\\..\\two");
|
|
|
|
lstrcpyA(path2, "two");
|
|
|
|
lstrcpyA(out, "aaa");
|
2006-07-13 02:19:55 +02:00
|
|
|
count = PathCommonPrefixA(path1, path2, out);
|
|
|
|
ok(count == 0, "Expected 0, got %i\n", count);
|
2013-10-15 21:41:10 +02:00
|
|
|
ok(!lstrcmpA(path1, "one\\..\\two"), "Expected one\\..\\two, got %s\n", path1);
|
|
|
|
ok(!lstrcmpA(path2, "two"), "Expected two, got %s\n", path2);
|
2014-11-03 23:21:35 +01:00
|
|
|
ok(!out[0], "Expected 0 length out, got %i\n", lstrlenA(out));
|
2006-10-06 12:43:34 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
|
2006-07-13 02:19:55 +02:00
|
|
|
}
|
|
|
|
|
2006-08-09 15:46:20 +02:00
|
|
|
static void test_PathUnquoteSpaces(void)
|
|
|
|
{
|
|
|
|
int i;
|
2018-06-26 22:44:25 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(TEST_PATH_UNQUOTE_SPACES); i++)
|
2006-08-09 15:46:20 +02:00
|
|
|
{
|
|
|
|
char *path = strdupA(TEST_PATH_UNQUOTE_SPACES[i].path);
|
|
|
|
WCHAR *pathW = GetWideString(TEST_PATH_UNQUOTE_SPACES[i].path);
|
|
|
|
WCHAR *resultW = GetWideString(TEST_PATH_UNQUOTE_SPACES[i].result);
|
|
|
|
|
|
|
|
PathUnquoteSpacesA(path);
|
|
|
|
ok(!strcmp(path, TEST_PATH_UNQUOTE_SPACES[i].result), "%s (A): got %s expected %s\n",
|
|
|
|
TEST_PATH_UNQUOTE_SPACES[i].path, path,
|
|
|
|
TEST_PATH_UNQUOTE_SPACES[i].result);
|
|
|
|
|
|
|
|
PathUnquoteSpacesW(pathW);
|
|
|
|
ok(!lstrcmpW(pathW, resultW), "%s (W): strings differ\n",
|
|
|
|
TEST_PATH_UNQUOTE_SPACES[i].path);
|
|
|
|
FreeWideString(pathW);
|
|
|
|
FreeWideString(resultW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:38:39 +01:00
|
|
|
static void test_PathGetDriveNumber(void)
|
|
|
|
{
|
|
|
|
static const CHAR test1A[] = "a:\\test.file";
|
|
|
|
static const CHAR test2A[] = "file:////b:\\test.file";
|
|
|
|
static const CHAR test3A[] = "file:///c:\\test.file";
|
|
|
|
static const CHAR test4A[] = "file:\\\\c:\\test.file";
|
2017-10-09 23:57:53 +02:00
|
|
|
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};
|
2010-03-03 10:38:39 +01:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = PathGetDriveNumberA(NULL);
|
|
|
|
ok(ret == -1, "got %d\n", ret);
|
|
|
|
ok(GetLastError() == 0xdeadbeef, "got %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = PathGetDriveNumberA(test1A);
|
|
|
|
ok(ret == 0, "got %d\n", ret);
|
2017-10-09 23:57:53 +02:00
|
|
|
ret = PathGetDriveNumberW(test1W);
|
|
|
|
ok(ret == 0, "got %d\n", ret);
|
2010-03-03 10:38:39 +01:00
|
|
|
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);
|
2017-10-09 23:57:53 +02:00
|
|
|
|
|
|
|
ret = PathGetDriveNumberA(test5A);
|
|
|
|
ok(ret == -1, "got %d\n", ret);
|
|
|
|
ret = PathGetDriveNumberW(test5W);
|
|
|
|
ok(ret == 2 || broken(ret == -1) /* winxp */, "got = %d\n", ret);
|
2010-03-03 10:38:39 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 10:39:09 +01:00
|
|
|
static void test_PathUnExpandEnvStrings(void)
|
|
|
|
{
|
|
|
|
static const WCHAR sysrootW[] = {'%','S','y','s','t','e','m','R','o','o','t','%',0};
|
|
|
|
static const WCHAR sysdriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%',0};
|
|
|
|
static const WCHAR nonpathW[] = {'p','a','t','h',0};
|
2018-02-23 18:33:12 +01:00
|
|
|
static const WCHAR computernameW[] = {'C','O','M','P','U','T','E','R','N','A','M','E',0};
|
2013-11-04 10:39:09 +01:00
|
|
|
static const char sysrootA[] = "%SystemRoot%";
|
|
|
|
static const char sysdriveA[] = "%SystemDrive%";
|
2018-02-23 18:33:12 +01:00
|
|
|
WCHAR pathW[MAX_PATH], buffW[MAX_PATH], sysdrvW[3], envvarW[30];
|
|
|
|
char path[MAX_PATH], buff[MAX_PATH], sysdrvA[3], envvarA[30];
|
2013-11-04 10:39:09 +01:00
|
|
|
BOOL ret;
|
|
|
|
UINT len;
|
|
|
|
|
|
|
|
if (!pPathUnExpandEnvStringsA || !pPathUnExpandEnvStringsW)
|
|
|
|
{
|
|
|
|
win_skip("PathUnExpandEnvStrings not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-23 18:33:12 +01:00
|
|
|
/* The value of ComputerName is not a path */
|
|
|
|
ret = GetEnvironmentVariableA("COMPUTERNAME", envvarA, sizeof(envvarA));
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pPathUnExpandEnvStringsA(envvarA, buff, sizeof(buff));
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
|
|
|
|
|
2018-06-26 22:44:25 +02:00
|
|
|
ret = GetEnvironmentVariableW(computernameW, envvarW, ARRAY_SIZE(envvarW));
|
2018-02-23 18:33:12 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
SetLastError(0xdeadbeef);
|
2018-06-26 22:44:25 +02:00
|
|
|
ret = pPathUnExpandEnvStringsW(envvarW, buffW, ARRAY_SIZE(buffW));
|
2018-02-23 18:33:12 +01:00
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
|
|
|
|
|
2013-11-04 10:39:09 +01:00
|
|
|
/* something that can't be represented with env var */
|
|
|
|
strcpy(path, "somepath_name");
|
|
|
|
strcpy(buff, "xx");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pPathUnExpandEnvStringsA(path, buff, sizeof(buff));
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
|
|
|
|
ok(buff[0] == 'x', "wrong return string %s\n", buff);
|
|
|
|
|
|
|
|
len = GetSystemDirectoryA(path, MAX_PATH);
|
|
|
|
ok(len > 0, "failed to get sysdir\n");
|
|
|
|
|
|
|
|
sysdrvA[0] = path[0];
|
|
|
|
strcpy(&sysdrvA[1], ":");
|
|
|
|
|
|
|
|
/* buffer size is not enough */
|
|
|
|
strcpy(buff, "xx");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pPathUnExpandEnvStringsA(path, buff, 5);
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d\n", ret);
|
|
|
|
ok(buff[0] == 'x', "wrong return string %s\n", buff);
|
|
|
|
|
|
|
|
/* buffer size is enough to hold variable name only */
|
|
|
|
strcpy(buff, "xx");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pPathUnExpandEnvStringsA(path, buff, sizeof(sysrootA));
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
|
|
|
|
ok(buff[0] == 'x', "wrong return string %s\n", buff);
|
|
|
|
|
|
|
|
/* enough size */
|
|
|
|
buff[0] = 0;
|
|
|
|
ret = pPathUnExpandEnvStringsA(path, buff, sizeof(buff));
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(!strncmp(buff, sysrootA, sizeof(sysrootA)-1), "wrong return string %s\n", buff);
|
|
|
|
|
|
|
|
/* expanded value occurs multiple times */
|
2014-02-07 22:42:49 +01:00
|
|
|
/* for drive C: it unexpands it like 'C:C:' -> '%SystemDrive%C:' */
|
2013-11-04 10:39:09 +01:00
|
|
|
buff[0] = 0;
|
|
|
|
strcpy(path, sysdrvA);
|
|
|
|
strcat(path, sysdrvA);
|
|
|
|
ret = pPathUnExpandEnvStringsA(path, buff, sizeof(buff));
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
/* expected string */
|
|
|
|
strcpy(path, sysdriveA);
|
|
|
|
strcat(path, sysdrvA);
|
|
|
|
ok(!strcmp(buff, path), "wrong unexpanded string %s, expected %s\n", buff, path);
|
|
|
|
|
|
|
|
/* now with altered variable */
|
|
|
|
ret = GetEnvironmentVariableA("SystemDrive", envvarA, sizeof(envvarA));
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = SetEnvironmentVariableA("SystemDrive", "WW");
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* variables are not cached */
|
|
|
|
strcpy(path, sysdrvA);
|
|
|
|
strcat(path, sysdrvA);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pPathUnExpandEnvStringsA(path, buff, sizeof(buff));
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
|
|
|
|
|
|
|
|
ret = SetEnvironmentVariableA("SystemDrive", envvarA);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* PathUnExpandEnvStringsW */
|
|
|
|
|
|
|
|
/* something that can't be represented with env var */
|
|
|
|
lstrcpyW(pathW, nonpathW);
|
|
|
|
buffW[0] = 'x'; buffW[1] = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
2018-06-26 22:44:25 +02:00
|
|
|
ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(buffW));
|
2013-11-04 10:39:09 +01:00
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
|
|
|
|
ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
|
|
|
|
|
|
|
|
len = GetSystemDirectoryW(pathW, MAX_PATH);
|
|
|
|
ok(len > 0, "failed to get sysdir\n");
|
|
|
|
|
|
|
|
sysdrvW[0] = pathW[0];
|
|
|
|
sysdrvW[1] = ':';
|
|
|
|
sysdrvW[2] = 0;
|
|
|
|
|
|
|
|
/* buffer size is not enough */
|
|
|
|
buffW[0] = 'x'; buffW[1] = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pPathUnExpandEnvStringsW(pathW, buffW, 5);
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
|
|
|
|
ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
|
|
|
|
|
|
|
|
/* buffer size is enough to hold variable name only */
|
|
|
|
buffW[0] = 'x'; buffW[1] = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
2018-06-26 22:44:25 +02:00
|
|
|
ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(sysrootW));
|
2013-11-04 10:39:09 +01:00
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
|
|
|
|
ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
|
|
|
|
|
|
|
|
/* enough size */
|
|
|
|
buffW[0] = 0;
|
2018-06-26 22:44:25 +02:00
|
|
|
ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(buffW));
|
2013-11-04 10:39:09 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(!memcmp(buffW, sysrootW, sizeof(sysrootW) - sizeof(WCHAR)), "wrong return string %s\n", wine_dbgstr_w(buffW));
|
|
|
|
|
|
|
|
/* expanded value occurs multiple times */
|
2014-02-07 22:42:49 +01:00
|
|
|
/* for drive C: it unexpands it like 'C:C:' -> '%SystemDrive%C:' */
|
2013-11-04 10:39:09 +01:00
|
|
|
buffW[0] = 0;
|
|
|
|
lstrcpyW(pathW, sysdrvW);
|
|
|
|
lstrcatW(pathW, sysdrvW);
|
2018-06-26 22:44:26 +02:00
|
|
|
ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(buffW));
|
2013-11-04 10:39:09 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
/* expected string */
|
|
|
|
lstrcpyW(pathW, sysdriveW);
|
|
|
|
lstrcatW(pathW, sysdrvW);
|
|
|
|
ok(!lstrcmpW(buffW, pathW), "wrong unexpanded string %s, expected %s\n", wine_dbgstr_w(buffW), wine_dbgstr_w(pathW));
|
|
|
|
}
|
2007-10-12 09:46:19 +02:00
|
|
|
|
2014-07-02 17:55:02 +02:00
|
|
|
static const struct {
|
|
|
|
const char *path;
|
|
|
|
BOOL expect;
|
|
|
|
} test_path_is_relative[] = {
|
|
|
|
{NULL, TRUE},
|
|
|
|
{"\0", TRUE},
|
|
|
|
{"test.txt", TRUE},
|
|
|
|
{"\\\\folder\\test.txt", FALSE},
|
|
|
|
{"file://folder/test.txt", TRUE},
|
|
|
|
{"C:\\test.txt", FALSE},
|
|
|
|
{"file:///C:/test.txt", TRUE}
|
|
|
|
};
|
|
|
|
|
2014-07-05 11:15:09 +02:00
|
|
|
static void test_PathIsRelativeA(void)
|
2014-07-02 17:55:02 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
int i, num;
|
|
|
|
|
|
|
|
if (!pPathIsRelativeA) {
|
|
|
|
win_skip("PathIsRelativeA not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-26 22:44:25 +02:00
|
|
|
num = ARRAY_SIZE(test_path_is_relative);
|
2014-07-02 17:55:02 +02:00
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
ret = pPathIsRelativeA(test_path_is_relative[i].path);
|
|
|
|
ok(ret == test_path_is_relative[i].expect,
|
|
|
|
"PathIsRelativeA(\"%s\") expects %d, got %d.\n",
|
|
|
|
test_path_is_relative[i].path, test_path_is_relative[i].expect, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-05 11:15:09 +02:00
|
|
|
static void test_PathIsRelativeW(void)
|
2014-07-02 17:55:02 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
int i, num;
|
|
|
|
LPWSTR path;
|
|
|
|
|
|
|
|
if (!pPathIsRelativeW) {
|
2014-10-02 10:30:06 +02:00
|
|
|
win_skip("PathIsRelativeW not available\n");
|
2014-07-02 17:55:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-26 22:44:25 +02:00
|
|
|
num = ARRAY_SIZE(test_path_is_relative);
|
2014-07-02 17:55:02 +02:00
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
path = GetWideString(test_path_is_relative[i].path);
|
|
|
|
|
|
|
|
ret = pPathIsRelativeW(path);
|
|
|
|
ok(ret == test_path_is_relative[i].expect,
|
|
|
|
"PathIsRelativeW(\"%s\") expects %d, got %d.\n",
|
|
|
|
test_path_is_relative[i].path, test_path_is_relative[i].expect, ret);
|
|
|
|
|
|
|
|
FreeWideString(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-28 20:05:12 +01:00
|
|
|
static void test_PathStripPathA(void)
|
|
|
|
{
|
|
|
|
const char const_path[] = "test";
|
|
|
|
char path[] = "short//path\\file.txt";
|
|
|
|
|
|
|
|
PathStripPathA(path);
|
|
|
|
ok(!strcmp(path, "file.txt"), "path = %s\n", path);
|
|
|
|
|
|
|
|
/* following test should not crash */
|
|
|
|
/* LavView 2013 depends on that behaviour */
|
|
|
|
PathStripPathA((char*)const_path);
|
|
|
|
}
|
|
|
|
|
2019-11-12 21:48:23 +01:00
|
|
|
static void test_PathUndecorate(void)
|
|
|
|
{
|
|
|
|
static const struct {
|
|
|
|
const WCHAR *path;
|
|
|
|
const WCHAR *expect;
|
|
|
|
} tests[] = {
|
|
|
|
{ L"c:\\test\\a[123]", L"c:\\test\\a" },
|
|
|
|
{ L"c:\\test\\a[123].txt", L"c:\\test\\a.txt" },
|
|
|
|
{ L"c:\\test\\a.txt[123]", L"c:\\test\\a.txt[123]" },
|
|
|
|
{ L"c:\\test\\a[123a].txt", L"c:\\test\\a[123a].txt" },
|
|
|
|
{ L"c:\\test\\a[a123].txt", L"c:\\test\\a[a123].txt" },
|
|
|
|
{ L"c:\\test\\a[12\x0660].txt", L"c:\\test\\a[12\x0660].txt" },
|
|
|
|
{ L"c:\\test\\a[12]file", L"c:\\test\\a[12]file" },
|
|
|
|
{ L"c:\\test[123]\\a", L"c:\\test[123]\\a" },
|
|
|
|
{ L"c:\\test\\[123]", L"c:\\test\\[123]" },
|
|
|
|
{ L"a[123]", L"a" },
|
|
|
|
{ L"a[]", L"a" },
|
|
|
|
{ L"[123]", L"[123]" }
|
|
|
|
};
|
|
|
|
char bufa[MAX_PATH], expect[MAX_PATH];
|
|
|
|
WCHAR buf[MAX_PATH];
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(tests); i++)
|
|
|
|
{
|
|
|
|
wcscpy(buf, tests[i].path);
|
|
|
|
PathUndecorateW(buf);
|
|
|
|
ok(!wcscmp(buf, tests[i].expect), "PathUndecorateW returned %s, expected %s\n",
|
|
|
|
wine_dbgstr_w(buf), wine_dbgstr_w(tests[i].expect));
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, tests[i].path, -1, bufa, ARRAY_SIZE(bufa), "?", NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, tests[i].expect, -1, expect, ARRAY_SIZE(expect), "?", NULL);
|
|
|
|
PathUndecorateA(bufa);
|
|
|
|
ok(!strcmp(bufa, expect), "PathUndecorateA returned %s, expected %s\n", bufa, expect);
|
|
|
|
}
|
|
|
|
|
|
|
|
PathUndecorateA(NULL);
|
|
|
|
PathUndecorateW(NULL);
|
|
|
|
}
|
|
|
|
|
2003-01-09 01:50:17 +01:00
|
|
|
START_TEST(path)
|
|
|
|
{
|
2010-03-03 10:38:39 +01:00
|
|
|
HMODULE hShlwapi = GetModuleHandleA("shlwapi.dll");
|
2005-02-10 18:10:43 +01:00
|
|
|
|
2010-10-10 15:11:22 +02:00
|
|
|
/* SHCreateStreamOnFileEx was introduced in shlwapi v6.0 */
|
|
|
|
if(!GetProcAddress(hShlwapi, "SHCreateStreamOnFileEx")){
|
|
|
|
win_skip("Too old shlwapi version\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:38:39 +01:00
|
|
|
pPathCreateFromUrlA = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlA");
|
|
|
|
pPathCreateFromUrlW = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlW");
|
2012-10-01 03:29:55 +02:00
|
|
|
pPathCreateFromUrlAlloc = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlAlloc");
|
2010-03-03 10:38:39 +01:00
|
|
|
pPathCombineW = (void*)GetProcAddress(hShlwapi, "PathCombineW");
|
|
|
|
pPathIsValidCharA = (void*)GetProcAddress(hShlwapi, (LPSTR)455);
|
|
|
|
pPathIsValidCharW = (void*)GetProcAddress(hShlwapi, (LPSTR)456);
|
|
|
|
pPathAppendA = (void*)GetProcAddress(hShlwapi, "PathAppendA");
|
2013-11-04 10:39:09 +01:00
|
|
|
pPathUnExpandEnvStringsA = (void*)GetProcAddress(hShlwapi, "PathUnExpandEnvStringsA");
|
|
|
|
pPathUnExpandEnvStringsW = (void*)GetProcAddress(hShlwapi, "PathUnExpandEnvStringsW");
|
2014-07-02 17:55:02 +02:00
|
|
|
pPathIsRelativeA = (void*)GetProcAddress(hShlwapi, "PathIsRelativeA");
|
|
|
|
pPathIsRelativeW = (void*)GetProcAddress(hShlwapi, "PathIsRelativeW");
|
2006-06-23 15:21:02 +02:00
|
|
|
|
2010-03-03 10:38:39 +01:00
|
|
|
test_PathSearchAndQualify();
|
|
|
|
test_PathCreateFromUrl();
|
|
|
|
test_PathIsUrl();
|
|
|
|
|
|
|
|
test_PathAddBackslash();
|
|
|
|
test_PathMakePretty();
|
|
|
|
test_PathMatchSpec();
|
2006-06-26 23:37:45 +02:00
|
|
|
|
2010-03-03 10:38:39 +01:00
|
|
|
test_PathIsValidCharA();
|
|
|
|
test_PathIsValidCharW();
|
|
|
|
|
|
|
|
test_PathCombineW();
|
|
|
|
test_PathCombineA();
|
|
|
|
test_PathAppendA();
|
|
|
|
test_PathCanonicalizeA();
|
|
|
|
test_PathFindExtensionA();
|
|
|
|
test_PathBuildRootA();
|
|
|
|
test_PathCommonPrefixA();
|
|
|
|
test_PathUnquoteSpaces();
|
|
|
|
test_PathGetDriveNumber();
|
2013-11-04 10:39:09 +01:00
|
|
|
test_PathUnExpandEnvStrings();
|
2014-07-02 17:55:02 +02:00
|
|
|
test_PathIsRelativeA();
|
|
|
|
test_PathIsRelativeW();
|
2015-10-28 20:05:12 +01:00
|
|
|
test_PathStripPathA();
|
2019-11-12 21:48:23 +01:00
|
|
|
test_PathUndecorate();
|
2003-01-09 01:50:17 +01:00
|
|
|
}
|