shell32: IShellFolder_SetNameOf fixes
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Fri Apr 15 09:54:10 CDT 2005
Huw Davies <huw at codeweavers.com>
When we're hiding file extensions then SetNameOf should append
the original extension if SHGDN_FORPARSING isn't set.
The flags passed to SetNameOf refer to the dst string not the
src pidl.
--
Huw Davies
huw at codeweavers.com
Index: dlls/shell32/shfldr_fs.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shfldr_fs.c,v
retrieving revision 1.36
diff -u -p -r1.36 shfldr_fs.c
--- dlls/shell32/shfldr_fs.c 23 Mar 2005 13:15:19 -0000 1.36
+++ dlls/shell32/shfldr_fs.c 15 Apr 2005 14:52:09 -0000
@@ -686,45 +686,46 @@ static const WCHAR HideFileExtW[] = { 'H
static const WCHAR NeverShowExtW[] = { 'N','e','v','e','r','S','h','o','w','E',
'x','t',0 };
-void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags)
+static BOOL hide_extension(LPWSTR szPath)
{
- /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
- if (!(dwFlags & SHGDN_FORPARSING) &&
- ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
- HKEY hKey;
- DWORD dwData;
- DWORD dwDataSize = sizeof (DWORD);
- BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
-
- if (!RegCreateKeyExW (HKEY_CURRENT_USER, AdvancedW,
- 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) {
- if (!RegQueryValueExW (hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData,
- &dwDataSize))
- doHide = dwData;
-
- RegCloseKey (hKey);
- }
+ HKEY hKey;
+ DWORD dwData;
+ DWORD dwDataSize = sizeof (DWORD);
+ BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
+
+ if (!RegCreateKeyExW(HKEY_CURRENT_USER, AdvancedW, 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) {
+ if (!RegQueryValueExW(hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, &dwDataSize))
+ doHide = dwData;
+ RegCloseKey (hKey);
+ }
- if (!doHide) {
- LPSTR ext = PathFindExtensionA(szPath);
+ if (!doHide) {
+ LPWSTR ext = PathFindExtensionW(szPath);
- if (ext) {
- char classname[MAX_PATH];
- LONG classlen = MAX_PATH;
-
- if (!RegQueryValueA(HKEY_CLASSES_ROOT, ext, classname,
- &classlen))
- if (!RegOpenKeyA(HKEY_CLASSES_ROOT, classname, &hKey)) {
- if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL,
- NULL, NULL))
- doHide = TRUE;
-
- RegCloseKey(hKey);
- }
- }
+ if (*ext != '\0') {
+ WCHAR classname[MAX_PATH];
+ LONG classlen = sizeof(classname);
+
+ if (!RegQueryValueW(HKEY_CLASSES_ROOT, ext, classname, &classlen))
+ if (!RegOpenKeyW(HKEY_CLASSES_ROOT, classname, &hKey)) {
+ if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, NULL, NULL))
+ doHide = TRUE;
+ RegCloseKey(hKey);
+ }
}
+ }
+ return doHide;
+}
+
+void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags)
+{
+ WCHAR pathW[MAX_PATH];
- if (doHide && szPath[0] != '.')
+ /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
+ if (!(dwFlags & SHGDN_FORPARSING) &&
+ ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
+ MultiByteToWideChar(CP_ACP, 0, szPath, -1, pathW, MAX_PATH);
+ if (hide_extension(pathW) && szPath[0] != '.')
PathRemoveExtensionA (szPath);
}
}
@@ -828,22 +829,30 @@ static HRESULT WINAPI IShellFolder_fnSet
debugstr_w (lpName), dwFlags, pPidlOut);
/* build source path */
- if (dwFlags & SHGDN_INFOLDER) {
- MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH);
- ptr = PathAddBackslashW (szSrc);
- if (ptr)
- _ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc));
- } else {
- /* FIXME: Can this work with a simple PIDL? */
- SHGetPathFromIDListW (pidl, szSrc);
- }
+ MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH);
+ ptr = PathAddBackslashW (szSrc);
+ if (ptr)
+ _ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc));
/* build destination path */
- MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH);
- ptr = PathAddBackslashW (szDest);
- if (ptr)
- lstrcpynW(ptr, lpName, MAX_PATH - (ptr - szDest));
+ if (dwFlags == SHGDN_NORMAL || dwFlags & SHGDN_INFOLDER) {
+ MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH);
+ ptr = PathAddBackslashW (szDest);
+ if (ptr)
+ lstrcpynW(ptr, lpName, MAX_PATH - (ptr - szDest));
+ } else
+ lstrcpynW(szDest, lpName, MAX_PATH);
+
+ if(!(dwFlags & SHGDN_FORPARSING) && hide_extension(szSrc)) {
+ WCHAR *ext = PathFindExtensionW(szSrc);
+ if(*ext != '\0') {
+ INT len = strlenW(szDest);
+ lstrcpynW(szDest + len, ext, MAX_PATH - len);
+ }
+ }
+
TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest));
+
if (MoveFileW (szSrc, szDest)) {
HRESULT hr = S_OK;
More information about the wine-patches
mailing list