Francois Gouget : shell32/tests: Copy the PathRemoveBackslashA() and PathAddBackslashW() implementations because shlwapi. dll is missing on Windows 95.
Alexandre Julliard
julliard at winehq.org
Tue Dec 18 07:34:48 CST 2007
Module: wine
Branch: master
Commit: 3874c55cc4a36e6f2fb705b6172b6e6fa81ff749
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3874c55cc4a36e6f2fb705b6172b6e6fa81ff749
Author: Francois Gouget <fgouget at free.fr>
Date: Tue Dec 18 10:00:47 2007 +0100
shell32/tests: Copy the PathRemoveBackslashA() and PathAddBackslashW() implementations because shlwapi.dll is missing on Windows 95.
---
dlls/shell32/tests/Makefile.in | 2 +-
dlls/shell32/tests/shellpath.c | 31 ++++++++++++++++++++++++++-----
dlls/shell32/tests/shlfolder.c | 30 +++++++++++++++++++++++++-----
3 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/dlls/shell32/tests/Makefile.in b/dlls/shell32/tests/Makefile.in
index cd15eb3..364bb3d 100644
--- a/dlls/shell32/tests/Makefile.in
+++ b/dlls/shell32/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = shell32.dll
-IMPORTS = shell32 ole32 oleaut32 shlwapi user32 advapi32 kernel32
+IMPORTS = shell32 ole32 oleaut32 user32 advapi32 kernel32
EXTRALIBS = -luuid
CTESTS = \
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c
index 8c237df..6fb485e 100644
--- a/dlls/shell32/tests/shellpath.c
+++ b/dlls/shell32/tests/shellpath.c
@@ -642,6 +642,27 @@ static void testEnvVars(void)
matchSpecialFolderPathToEnv(CSIDL_SYSTEM, "winsysdir");
}
+/* Loosely based on PathRemoveBackslashA from dlls/shlwapi/path.c */
+static BOOL myPathIsRootA(LPCSTR lpszPath)
+{
+ if (lpszPath && *lpszPath &&
+ lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
+ return TRUE; /* X:\ */
+ return FALSE;
+}
+static LPSTR myPathRemoveBackslashA( LPSTR lpszPath )
+{
+ LPSTR szTemp = NULL;
+
+ if(lpszPath)
+ {
+ szTemp = CharPrevA(lpszPath, lpszPath + strlen(lpszPath));
+ if (!myPathIsRootA(lpszPath) && *szTemp == '\\')
+ *szTemp = '\0';
+ }
+ return szTemp;
+}
+
/* Verifies the shell path for CSIDL_WINDOWS matches the return from
* GetWindowsDirectory. If SHGetSpecialFolderPath fails, no harm, no foul--not
* every shell32 version supports CSIDL_WINDOWS.
@@ -654,9 +675,9 @@ static void testWinDir(void)
if (pSHGetSpecialFolderPathA(NULL, windowsShellPath, CSIDL_WINDOWS, FALSE))
{
- PathRemoveBackslashA(windowsShellPath);
+ myPathRemoveBackslashA(windowsShellPath);
GetWindowsDirectoryA(windowsDir, sizeof(windowsDir));
- PathRemoveBackslashA(windowsDir);
+ myPathRemoveBackslashA(windowsDir);
ok(!lstrcmpiA(windowsDir, windowsShellPath),
"GetWindowsDirectory does not match SHGetSpecialFolderPath:\n"
"GetWindowsDirectory returns %s\nSHGetSpecialFolderPath returns %s\n",
@@ -675,10 +696,10 @@ static void testSystemDir(void)
if (!pSHGetSpecialFolderPathA) return;
GetSystemDirectoryA(systemDir, sizeof(systemDir));
- PathRemoveBackslashA(systemDir);
+ myPathRemoveBackslashA(systemDir);
if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEM, FALSE))
{
- PathRemoveBackslashA(systemShellPath);
+ myPathRemoveBackslashA(systemShellPath);
ok(!lstrcmpiA(systemDir, systemShellPath),
"GetSystemDirectory does not match SHGetSpecialFolderPath:\n"
"GetSystemDirectory returns %s\nSHGetSpecialFolderPath returns %s\n",
@@ -689,7 +710,7 @@ static void testSystemDir(void)
*/
if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEMX86, FALSE))
{
- PathRemoveBackslashA(systemShellPath);
+ myPathRemoveBackslashA(systemShellPath);
ok(!lstrcmpiA(systemDir, systemShellPath),
"GetSystemDirectory does not match SHGetSpecialFolderPath:\n"
"GetSystemDirectory returns %s\nSHGetSpecialFolderPath returns %s\n",
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index 0cf398a..721b9da 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -324,7 +324,27 @@ static void test_BindToObject(void)
IShellFolder_Release(psfSystemDir);
}
-
+
+/* Based on PathAddBackslashW from dlls/shlwapi/path.c */
+static LPWSTR myPathAddBackslashW( LPWSTR lpszPath )
+{
+ size_t iLen;
+
+ if (!lpszPath || (iLen = lstrlenW(lpszPath)) >= MAX_PATH)
+ return NULL;
+
+ if (iLen)
+ {
+ lpszPath += iLen;
+ if (lpszPath[-1] != '\\')
+ {
+ *lpszPath++ = '\\';
+ *lpszPath = '\0';
+ }
+ }
+ return lpszPath;
+}
+
static void test_GetDisplayName(void)
{
BOOL result;
@@ -357,7 +377,7 @@ static void test_GetDisplayName(void)
ok(result, "SHGetSpecialFolderPathW failed! Last error: %u\n", GetLastError());
if (!result) return;
- PathAddBackslashW(wszTestDir);
+ myPathAddBackslashW(wszTestDir);
lstrcatW(wszTestDir, wszDirName);
/* Use ANSI file functions so this works on Windows 9x */
WideCharToMultiByte(CP_ACP, 0, wszTestDir, -1, szTestDir, MAX_PATH, 0, 0);
@@ -370,7 +390,7 @@ static void test_GetDisplayName(void)
}
lstrcpyW(wszTestFile, wszTestDir);
- PathAddBackslashW(wszTestFile);
+ myPathAddBackslashW(wszTestFile);
lstrcatW(wszTestFile, wszFileName);
WideCharToMultiByte(CP_ACP, 0, wszTestFile, -1, szTestFile, MAX_PATH, 0, 0);
@@ -824,7 +844,7 @@ static void test_SHGetPathFromIDList(void)
IShellFolder_Release(psfDesktop);
return;
}
- PathAddBackslashW(wszFileName);
+ myPathAddBackslashW(wszFileName);
lstrcatW(wszFileName, wszTestFile);
hTestFile = CreateFileW(wszFileName, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
ok(hTestFile != INVALID_HANDLE_VALUE, "CreateFileW failed! Last error: %u\n", GetLastError());
@@ -1153,7 +1173,7 @@ static void test_FolderShortcut(void) {
/* Next few lines are meant to show that children of FolderShortcuts are not FolderShortcuts,
* but ShellFSFolders. */
- PathAddBackslashW(wszDesktopPath);
+ myPathAddBackslashW(wszDesktopPath);
lstrcatW(wszDesktopPath, wszSomeSubFolder);
if (!CreateDirectoryW(wszDesktopPath, NULL)) {
IShellFolder_Release(pShellFolder);
More information about the wine-cvs
mailing list