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.
This commit is contained in:
parent
35356002e6
commit
7ac969d560
|
@ -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',
|
static const WCHAR NeverShowExtW[] = { 'N','e','v','e','r','S','h','o','w','E',
|
||||||
'x','t',0 };
|
'x','t',0 };
|
||||||
|
|
||||||
|
static BOOL hide_extension(LPWSTR 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 (!doHide) {
|
||||||
|
LPWSTR ext = PathFindExtensionW(szPath);
|
||||||
|
|
||||||
|
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)
|
void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
|
WCHAR pathW[MAX_PATH];
|
||||||
|
|
||||||
/*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
|
/*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
|
||||||
if (!(dwFlags & SHGDN_FORPARSING) &&
|
if (!(dwFlags & SHGDN_FORPARSING) &&
|
||||||
((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
|
((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
|
||||||
HKEY hKey;
|
MultiByteToWideChar(CP_ACP, 0, szPath, -1, pathW, MAX_PATH);
|
||||||
DWORD dwData;
|
if (hide_extension(pathW) && szPath[0] != '.')
|
||||||
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 (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 (doHide && szPath[0] != '.')
|
|
||||||
PathRemoveExtensionA (szPath);
|
PathRemoveExtensionA (szPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -828,22 +829,30 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface,
|
||||||
debugstr_w (lpName), dwFlags, pPidlOut);
|
debugstr_w (lpName), dwFlags, pPidlOut);
|
||||||
|
|
||||||
/* build source path */
|
/* build source path */
|
||||||
if (dwFlags & SHGDN_INFOLDER) {
|
MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH);
|
||||||
MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH);
|
ptr = PathAddBackslashW (szSrc);
|
||||||
ptr = PathAddBackslashW (szSrc);
|
if (ptr)
|
||||||
if (ptr)
|
_ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc));
|
||||||
_ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc));
|
|
||||||
} else {
|
|
||||||
/* FIXME: Can this work with a simple PIDL? */
|
|
||||||
SHGetPathFromIDListW (pidl, szSrc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* build destination path */
|
/* build destination path */
|
||||||
MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH);
|
if (dwFlags == SHGDN_NORMAL || dwFlags & SHGDN_INFOLDER) {
|
||||||
ptr = PathAddBackslashW (szDest);
|
MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH);
|
||||||
if (ptr)
|
ptr = PathAddBackslashW (szDest);
|
||||||
lstrcpynW(ptr, lpName, MAX_PATH - (ptr - 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));
|
TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest));
|
||||||
|
|
||||||
if (MoveFileW (szSrc, szDest)) {
|
if (MoveFileW (szSrc, szDest)) {
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue