From 990ea44e981f060c7bfeeb973e7932df7cf237b6 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Thu, 4 Nov 2004 04:54:08 +0000 Subject: [PATCH] Implementation of PathCleanupSpec. --- dlls/shell32/shell32.spec | 2 +- dlls/shell32/shellpath.c | 73 ++++++++++++++++++++++++++++++++++++--- dlls/shell32/undocshell.h | 8 ----- include/shlobj.h | 7 ++++ 4 files changed, 77 insertions(+), 13 deletions(-) diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec index ba34c4213f5..fea44300c8f 100644 --- a/dlls/shell32/shell32.spec +++ b/dlls/shell32/shell32.spec @@ -162,7 +162,7 @@ 168 stdcall SHCreatePropSheetExtArray(long str long) 169 stdcall SHDestroyPropSheetExtArray(long) 170 stdcall SHReplaceFromPropSheetExtArray(long long long long) - 171 stdcall PathCleanupSpec(ptr ptr) PathCleanupSpecAW + 171 stdcall PathCleanupSpec(ptr ptr) 172 stdcall SHCreateLinks(long str ptr long ptr) 173 stdcall SHValidateUNC(long long long) 174 stdcall SHCreateShellFolderViewEx (ptr ptr) diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 72b220a641a..3f079a1b155 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -558,11 +558,76 @@ BOOL WINAPI PathFindOnPathAW(LPVOID sFile, LPCVOID sOtherDirs) /************************************************************************* * PathCleanupSpec [SHELL32.171] + * + * lpszFile is changed in place. */ -DWORD WINAPI PathCleanupSpecAW (LPCVOID x, LPVOID y) +int WINAPI PathCleanupSpec( LPCWSTR lpszPathW, LPWSTR lpszFileW ) { - FIXME("(%p, %p) stub\n",x,y); - return TRUE; + int i = 0; + DWORD rc = 0; + int length = 0; + + if (SHELL_OsIsUnicode()) + { + LPWSTR p = lpszFileW; + + TRACE("Cleanup %s\n",debugstr_w(lpszFileW)); + + if (lpszPathW) + length = strlenW(lpszPathW); + + while (*p) + { + int gct = PathGetCharTypeW(*p); + if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR) + { + lpszFileW[i]='-'; + rc |= PCS_REPLACEDCHAR; + } + else + lpszFileW[i]=*p; + i++; + p++; + if (length + i == MAX_PATH) + { + rc |= PCS_FATAL | PCS_PATHTOOLONG; + break; + } + } + lpszFileW[i]=0; + } + else + { + LPSTR lpszFileA = (LPSTR)lpszFileW; + LPCSTR lpszPathA = (LPSTR)lpszPathW; + LPSTR p = lpszFileA; + + TRACE("Cleanup %s\n",debugstr_a(lpszFileA)); + + if (lpszPathA) + length = strlen(lpszPathA); + + while (*p) + { + int gct = PathGetCharTypeA(*p); + if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR) + { + lpszFileA[i]='-'; + rc |= PCS_REPLACEDCHAR; + } + else + lpszFileA[i]=*p; + i++; + p++; + if (length + i == MAX_PATH) + { + rc |= PCS_FATAL | PCS_PATHTOOLONG; + break; + } + } + lpszFileA[i]=0; + } + return rc; } /************************************************************************* @@ -1182,7 +1247,7 @@ static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath) { HRESULT hr; WCHAR resourcePath[MAX_PATH]; - LPCWSTR pDefaultPath; + LPCWSTR pDefaultPath = NULL; TRACE("0x%02x,%p\n", folder, pszPath); diff --git a/dlls/shell32/undocshell.h b/dlls/shell32/undocshell.h index 9eaafb685df..a661da1f9d7 100644 --- a/dlls/shell32/undocshell.h +++ b/dlls/shell32/undocshell.h @@ -429,14 +429,6 @@ BOOL WINAPI PathYetAnotherMakeUniqueName( LPCWSTR lpszShortName, LPCWSTR lpszLongName); -/* PathCleanupSpec return values */ -#define PCS_REPLACEDCHARS 0x00000001 -#define PCS_REMOVEDCHARS 0x00000002 -#define PCS_SHORTENED 0x00000004 -#define PCS_PATHTOOLONG 0x80000008 - -DWORD WINAPI PathCleanupSpecAW(LPCVOID lpszPath, LPVOID lpszFile); - BOOL WINAPI PathQualifyA(LPCSTR path); BOOL WINAPI PathQualifyW(LPCWSTR path); #define PathQualify WINELIB_NAME_AW(PathQualify) diff --git a/include/shlobj.h b/include/shlobj.h index 7cda4f07fc5..839f8bfd2bb 100644 --- a/include/shlobj.h +++ b/include/shlobj.h @@ -62,6 +62,13 @@ int WINAPI RestartDialogEx(HWND,LPCWSTR,DWORD,DWORD); BOOL WINAPI SHObjectProperties(HWND,UINT,LPCWSTR,LPCWSTR); +#define PCS_FATAL 0x80000000 +#define PCS_REPLACEDCHAR 0x00000001 +#define PCS_REMOVEDCHAR 0x00000002 +#define PCS_TRUNCATED 0x00000004 +#define PCS_PATHTOOLONG 0x00000008 + +int WINAPI PathCleanupSpec(LPCWSTR pszDir, LPWSTR pszSpec); /***************************************************************************** * Predeclare interfaces