From 2b3fea0249de423a3056a3ba3215fa86cb057e6e Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Mon, 28 Jun 2010 09:35:36 -0500 Subject: [PATCH] shell32: Pass the file extension to ParseDisplayName in unixfs's SetNameOf. --- dlls/shell32/shfldr_unixfs.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dlls/shell32/shfldr_unixfs.c b/dlls/shell32/shfldr_unixfs.c index dfd7255407f..9c9f94afad6 100644 --- a/dlls/shell32/shfldr_unixfs.c +++ b/dlls/shell32/shfldr_unixfs.c @@ -1183,9 +1183,9 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_SetNameOf(IShellFolder2* iface, H static const WCHAR awcInvalidChars[] = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }; char szSrc[FILENAME_MAX], szDest[FILENAME_MAX]; - WCHAR wszSrcRelative[MAX_PATH]; + WCHAR wszSrcRelative[MAX_PATH], *pwszExt = NULL; unsigned int i; - int cBasePathLen = lstrlenA(This->m_pszPath); + int cBasePathLen = lstrlenA(This->m_pszPath), cNameLen; struct stat statDest; LPITEMIDLIST pidlSrc, pidlDest, pidlRelativeDest; LPOLESTR lpwszName; @@ -1221,8 +1221,8 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_SetNameOf(IShellFolder2* iface, H _ILSimpleGetTextW(pidl, wszSrcRelative, MAX_PATH) && SHELL_FS_HideExtension(wszSrcRelative)) { - WCHAR *pwszExt = PathFindExtensionW(wszSrcRelative); int cLenDest = strlen(szDest); + pwszExt = PathFindExtensionW(wszSrcRelative); WideCharToMultiByte(CP_UNIXCP, 0, pwszExt, -1, szDest + cLenDest, FILENAME_MAX - cLenDest, NULL, NULL); } @@ -1238,8 +1238,14 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_SetNameOf(IShellFolder2* iface, H return E_FAIL; /* Build a pidl for the path of the renamed file */ - lpwszName = SHAlloc((lstrlenW(lpcwszName)+1)*sizeof(WCHAR)); /* due to const correctness. */ + cNameLen = lstrlenW(lpcwszName) + 1; + if(pwszExt) + cNameLen += lstrlenW(pwszExt); + lpwszName = SHAlloc(cNameLen*sizeof(WCHAR)); /* due to const correctness. */ lstrcpyW(lpwszName, lpcwszName); + if(pwszExt) + lstrcatW(lpwszName, pwszExt); + hr = IShellFolder2_ParseDisplayName(iface, NULL, NULL, lpwszName, NULL, &pidlRelativeDest, NULL); SHFree(lpwszName); if (FAILED(hr)) {