From 7d1df593703cc890e82aaa6f918a1d703ffba69b Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 9 Jul 2012 13:49:08 -0300 Subject: [PATCH] Win32: Show filename with extension instead of display name for files. If the user has the "hide extensions for known file types" option selected in Windows Explorer, the display name will not contain the file extension, so it's better to use the filename (with extension) directly. --- src/file_system.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/file_system.cpp b/src/file_system.cpp index 3aab4a73d..b362d775d 100644 --- a/src/file_system.cpp +++ b/src/file_system.cpp @@ -756,21 +756,23 @@ static void update_by_pidl(FileItem* fileitem) /****************************************/ /* get the name to display */ - if (pFolder && + if (fileitem->isFolder() && + pFolder && pFolder->GetDisplayNameOf(fileitem->pidl, SHGDN_INFOLDER, &strret) == S_OK) { StrRetToBuf(&strret, fileitem->pidl, pszName, MAX_PATH); fileitem->displayname = pszName; } - else if (shl_idesktop->GetDisplayNameOf(fileitem->fullpidl, + else if (fileitem->isFolder() && + shl_idesktop->GetDisplayNameOf(fileitem->fullpidl, SHGDN_INFOLDER, &strret) == S_OK) { StrRetToBuf(&strret, fileitem->fullpidl, pszName, MAX_PATH); fileitem->displayname = pszName; } else { - fileitem->displayname = "ERR"; + fileitem->displayname = base::get_file_name(fileitem->filename); } if (pFolder != NULL && pFolder != shl_idesktop) { @@ -951,10 +953,9 @@ static FileItem* get_fileitem_by_fullpidl(LPITEMIDLIST fullpidl, bool create_if_ fileitem->fullpidl = clone_pidl(fullpidl); fileitem->attrib = SFGAO_FOLDER; - shl_idesktop->GetAttributesOf(1, (LPCITEMIDLIST *)&fileitem->fullpidl, - &fileitem->attrib); - - { + HRESULT hr = shl_idesktop->GetAttributesOf(1, (LPCITEMIDLIST *)&fileitem->fullpidl, + &fileitem->attrib); + if (hr == S_OK) { LPITEMIDLIST parent_fullpidl = clone_pidl(fileitem->fullpidl); remove_last_pidl(parent_fullpidl);