From 110fc5dee14fc7988f631a158e50d283446aba7a Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:24:09 +0200 Subject: 5.15 --- zen/IFileOperation/FileOperation_Vista.vcxproj | 35 ++++++++++---------------- zen/IFileOperation/file_op.cpp | 28 +++++++++++++++------ 2 files changed, 33 insertions(+), 30 deletions(-) (limited to 'zen/IFileOperation') diff --git a/zen/IFileOperation/FileOperation_Vista.vcxproj b/zen/IFileOperation/FileOperation_Vista.vcxproj index 73bfd56a..4694a3a5 100644 --- a/zen/IFileOperation/FileOperation_Vista.vcxproj +++ b/zen/IFileOperation/FileOperation_Vista.vcxproj @@ -88,7 +88,7 @@ Disabled - _DEBUG;_WINDOWS;_USRDLL;FILE_OP_DLL_EXPORTS;%(PreprocessorDefinitions) + WXINTL_NO_GETTEXT_MACRO;FFS_WIN;_DEBUG;_WINDOWS;_USRDLL;FILE_OP_DLL_EXPORTS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -97,7 +97,7 @@ Level4 true EditAndContinue - 4100;4996 + 4100;4996;4512 ../..;C:\Program Files\C++\boost true @@ -124,7 +124,7 @@ Disabled - _DEBUG;_WINDOWS;_USRDLL;FILE_OP_DLL_EXPORTS;%(PreprocessorDefinitions) + WXINTL_NO_GETTEXT_MACRO;FFS_WIN;_DEBUG;_WINDOWS;_USRDLL;FILE_OP_DLL_EXPORTS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -133,7 +133,7 @@ Level4 true ProgramDatabase - 4100;4996 + 4100;4996;4512 ../..;C:\Program Files\C++\boost true @@ -158,7 +158,7 @@ MaxSpeed true - NDEBUG;_WINDOWS;_USRDLL;FILE_OP_DLL_EXPORTS;%(PreprocessorDefinitions) + WXINTL_NO_GETTEXT_MACRO;FFS_WIN;NDEBUG;_WINDOWS;_USRDLL;FILE_OP_DLL_EXPORTS;%(PreprocessorDefinitions) MultiThreaded true @@ -167,7 +167,7 @@ true ProgramDatabase Speed - 4100;4996 + 4100;4996;4512 ../..;C:\Program Files\C++\boost @@ -196,7 +196,7 @@ MaxSpeed true - NDEBUG;_WINDOWS;_USRDLL;FILE_OP_DLL_EXPORTS;%(PreprocessorDefinitions) + WXINTL_NO_GETTEXT_MACRO;FFS_WIN;NDEBUG;_WINDOWS;_USRDLL;FILE_OP_DLL_EXPORTS;%(PreprocessorDefinitions) MultiThreaded true @@ -205,7 +205,7 @@ true ProgramDatabase Speed - 4100;4996 + 4100;4996;4512 ../..;C:\Program Files\C++\boost @@ -226,20 +226,11 @@ - - - - false - - - false - - - false - - - false - + + + + + diff --git a/zen/IFileOperation/file_op.cpp b/zen/IFileOperation/file_op.cpp index b3990ee0..8816b502 100644 --- a/zen/IFileOperation/file_op.cpp +++ b/zen/IFileOperation/file_op.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -98,12 +99,18 @@ public: if (psiItem) { LPWSTR itemPath = nullptr; - HRESULT hr = psiItem->GetDisplayName(SIGDN_FILESYSPATH, &itemPath); - if (FAILED(hr)) - return hr; - ZEN_ON_SCOPE_EXIT(::CoTaskMemFree(itemPath)); - - currentItem = itemPath; + if (SUCCEEDED(psiItem->GetDisplayName(SIGDN_FILESYSPATH, &itemPath))) //will fail for long file paths > MAX_PATH! + { + ZEN_ON_SCOPE_EXIT(::CoTaskMemFree(itemPath)); + currentItem = itemPath; + } + else if (SUCCEEDED(psiItem->GetDisplayName(SIGDN_NORMALDISPLAY, &itemPath))) //short name only; should work even for long file paths! + { + ZEN_ON_SCOPE_EXIT(::CoTaskMemFree(itemPath)); + currentItem = itemPath; + } + else + currentItem = L""; //give some indication that file name determination failed (rather than leaving the name empty!) } //"Returns S_OK if successful, or an error value otherwise. In the case of an error value, the delete operation //and all subsequent operations pending from the call to IFileOperation are canceled." @@ -222,7 +229,12 @@ void moveToRecycleBin(const wchar_t* fileNames[], //throw ComError { if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || //file not existing anymore hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)) - continue; + { + //make sure the file really is not there: Win32 by default strips trailing spaces, so we might end up here in error! + //on the other hand, shell layer does not support \\?\ prefix to prevent this! + if (!somethingExists(fileNames[i])) + continue; + } throw ComError(std::wstring(L"Error calling \"SHCreateItemFromParsingName\" for file:\n") + L"\'" + fileNames[i] + L"\'.", hr); } @@ -231,7 +243,7 @@ void moveToRecycleBin(const wchar_t* fileNames[], //throw ComError ++operationCount; } - if (operationCount == 0) //calling PerformOperations() without anything to do would yielt E_UNEXPECTED + if (operationCount == 0) //calling PerformOperations() without anything to do would yield E_UNEXPECTED return; //perform planned operations -- cgit