summaryrefslogtreecommitdiff
path: root/shared/IFileOperation/file_op.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'shared/IFileOperation/file_op.cpp')
-rw-r--r--shared/IFileOperation/file_op.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/shared/IFileOperation/file_op.cpp b/shared/IFileOperation/file_op.cpp
index a2cf9413..8b632972 100644
--- a/shared/IFileOperation/file_op.cpp
+++ b/shared/IFileOperation/file_op.cpp
@@ -61,13 +61,15 @@ bool fileop::moveToRecycleBin(const wchar_t* fileNames[],
return false;
}
+ int operationCount = 0;
+
for (size_t i = 0; i < fileNo; ++i)
{
//create file/folder item object
ComPtr<IShellItem> psiFile;
- hr = SHCreateItemFromParsingName(fileNames[i],
- NULL,
- IID_PPV_ARGS(psiFile.init()));
+ hr = ::SHCreateItemFromParsingName(fileNames[i],
+ NULL,
+ IID_PPV_ARGS(psiFile.init()));
if (FAILED(hr))
{
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || //file not existing anymore
@@ -87,8 +89,13 @@ bool fileop::moveToRecycleBin(const wchar_t* fileNames[],
lastErrorMessage = generateErrorMsg(L"Error calling \"DeleteItem\".", hr);
return false;
}
+
+ ++operationCount;
}
+ if (operationCount == 0) //calling PerformOperations() without anything to do results in E_UNEXPECTED
+ return true;
+
//perform actual operations
hr = fileOp->PerformOperations();
if (FAILED(hr))
bgstack15