Commit 7ac969d5 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

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.
parent 35356002
......@@ -686,45 +686,46 @@ static const WCHAR HideFileExtW[] = { 'H','i','d','e','F','i','l','e','E','x',
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);
}
if (!doHide) {
LPSTR ext = PathFindExtensionA(szPath);
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 (ext) {
char classname[MAX_PATH];
LONG classlen = MAX_PATH;
if (!doHide) {
LPWSTR ext = PathFindExtensionW(szPath);
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;
if (*ext != '\0') {
WCHAR classname[MAX_PATH];
LONG classlen = sizeof(classname);
RegCloseKey(hKey);
}
}
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_fnSetNameOf (IShellFolder2 * iface,
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment