diff options
Diffstat (limited to 'shared/IFileOperation/file_op.cpp')
-rw-r--r-- | shared/IFileOperation/file_op.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/shared/IFileOperation/file_op.cpp b/shared/IFileOperation/file_op.cpp index b1b7f4cd..fc942f44 100644 --- a/shared/IFileOperation/file_op.cpp +++ b/shared/IFileOperation/file_op.cpp @@ -36,10 +36,10 @@ bool fileop::moveToRecycleBin(const wchar_t* fileNames[], // Create the IFileOperation interface ComPtr<IFileOperation> fileOp; - hr = CoCreateInstance(CLSID_FileOperation, - NULL, - CLSCTX_ALL, - IID_PPV_ARGS(fileOp.init())); + hr = ::CoCreateInstance(CLSID_FileOperation, + NULL, + CLSCTX_ALL, + IID_PPV_ARGS(fileOp.init())); if (FAILED(hr)) { lastErrorMessage = generateErrorMsg(L"Error calling \"CoCreateInstance\".", hr); @@ -70,6 +70,10 @@ bool fileop::moveToRecycleBin(const wchar_t* fileNames[], IID_PPV_ARGS(psiFile.init())); if (FAILED(hr)) { + if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || //file not existing anymore + hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)) + continue; + std::wstring message(L"Error calling \"SHCreateItemFromParsingName\" for file:\n"); message += std::wstring(L"\"") + fileNames[i] + L"\"."; @@ -122,10 +126,10 @@ bool fileop::copyFile(const wchar_t* sourceFile, // Create the IFileOperation interface ComPtr<IFileOperation> fileOp; - hr = CoCreateInstance(CLSID_FileOperation, - NULL, - CLSCTX_ALL, - IID_PPV_ARGS(fileOp.init())); + hr = ::CoCreateInstance(CLSID_FileOperation, + NULL, + CLSCTX_ALL, + IID_PPV_ARGS(fileOp.init())); if (FAILED(hr)) { lastErrorMessage = generateErrorMsg(L"Error calling \"CoCreateInstance\".", hr); @@ -148,9 +152,9 @@ bool fileop::copyFile(const wchar_t* sourceFile, //create source object ComPtr<IShellItem> psiSourceFile; - hr = SHCreateItemFromParsingName(sourceFile, - NULL, - IID_PPV_ARGS(psiSourceFile.init())); + hr = ::SHCreateItemFromParsingName(sourceFile, + NULL, + IID_PPV_ARGS(psiSourceFile.init())); if (FAILED(hr)) { std::wstring message(L"Error calling \"SHCreateItemFromParsingName\" for file:\n"); @@ -171,9 +175,9 @@ bool fileop::copyFile(const wchar_t* sourceFile, //create target folder object ComPtr<IShellItem> psiTargetFolder; - hr = SHCreateItemFromParsingName(targetFolder.c_str(), - NULL, - IID_PPV_ARGS(psiTargetFolder.init())); + hr = ::SHCreateItemFromParsingName(targetFolder.c_str(), + NULL, + IID_PPV_ARGS(psiTargetFolder.init())); if (FAILED(hr)) { std::wstring message(L"Error calling \"SHCreateItemFromParsingName\" for folder:\n"); |