diff options
Diffstat (limited to 'zen/IFileOperation')
-rw-r--r-- | zen/IFileOperation/file_op.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/zen/IFileOperation/file_op.cpp b/zen/IFileOperation/file_op.cpp index 0691ac5b..b3990ee0 100644 --- a/zen/IFileOperation/file_op.cpp +++ b/zen/IFileOperation/file_op.cpp @@ -166,14 +166,14 @@ void moveToRecycleBin(const wchar_t* fileNames[], //throw ComError void* sink) { ComPtr<IFileOperation> fileOp; - ZEN_CHECK_COM(::CoCreateInstance(CLSID_FileOperation, //throw ComError + ZEN_COM_CHECK(::CoCreateInstance(CLSID_FileOperation, //throw ComError nullptr, CLSCTX_ALL, IID_PPV_ARGS(fileOp.init()))); // Set the operation flags. Turn off all UI from being shown to the user during the // operation. This includes error, confirmation and progress dialogs. - ZEN_CHECK_COM(fileOp->SetOperationFlags(FOF_ALLOWUNDO | + ZEN_COM_CHECK(fileOp->SetOperationFlags(FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_SILENT | //no progress dialog box FOF_NOERRORUI | @@ -192,7 +192,7 @@ void moveToRecycleBin(const wchar_t* fileNames[], //throw ComError throw ComError(L"Error creating RecyclerProgressCallback.", E_OUTOFMEMORY); DWORD callbackID = 0; - ZEN_CHECK_COM(fileOp->Advise(opProgress.get(), &callbackID)); + ZEN_COM_CHECK(fileOp->Advise(opProgress.get(), &callbackID)); ZEN_ON_SCOPE_EXIT(fileOp->Unadvise(callbackID)); //RecyclerProgressCallback might outlive current scope, so cut access to "callback, sink" int operationCount = 0; @@ -226,7 +226,7 @@ void moveToRecycleBin(const wchar_t* fileNames[], //throw ComError throw ComError(std::wstring(L"Error calling \"SHCreateItemFromParsingName\" for file:\n") + L"\'" + fileNames[i] + L"\'.", hr); } - ZEN_CHECK_COM(fileOp->DeleteItem(psiFile.get(), nullptr)); + ZEN_COM_CHECK(fileOp->DeleteItem(psiFile.get(), nullptr)); ++operationCount; } @@ -237,7 +237,7 @@ void moveToRecycleBin(const wchar_t* fileNames[], //throw ComError //perform planned operations try { - ZEN_CHECK_COM(fileOp->PerformOperations()); + ZEN_COM_CHECK(fileOp->PerformOperations()); } catch (const ComError&) { @@ -263,7 +263,7 @@ void moveToRecycleBin(const wchar_t* fileNames[], //throw ComError //if FOF_NOERRORUI without FOFX_EARLYFAILURE is set, PerformOperations() can return with success despite errors, but sets the following "aborted" flag instead BOOL pfAnyOperationsAborted = FALSE; - ZEN_CHECK_COM(fileOp->GetAnyOperationsAborted(&pfAnyOperationsAborted)); + ZEN_COM_CHECK(fileOp->GetAnyOperationsAborted(&pfAnyOperationsAborted)); if (pfAnyOperationsAborted == TRUE) throw ComError(L"Operation did not complete successfully."); @@ -274,7 +274,7 @@ void copyFile(const wchar_t* sourceFile, //throw ComError const wchar_t* targetFile) { ComPtr<IFileOperation> fileOp; - ZEN_CHECK_COM(::CoCreateInstance(CLSID_FileOperation, //throw ComError + ZEN_COM_CHECK(::CoCreateInstance(CLSID_FileOperation, //throw ComError nullptr, CLSCTX_ALL, IID_PPV_ARGS(fileOp.init()))); @@ -283,7 +283,7 @@ void copyFile(const wchar_t* sourceFile, //throw ComError // from being shown to the user during the // operation. This includes error, confirmation // and progress dialogs. - ZEN_CHECK_COM(fileOp->SetOperationFlags(FOF_NOCONFIRMATION | //throw ComError + ZEN_COM_CHECK(fileOp->SetOperationFlags(FOF_NOCONFIRMATION | //throw ComError FOF_SILENT | FOFX_EARLYFAILURE | FOF_NOERRORUI)); @@ -315,14 +315,14 @@ void copyFile(const wchar_t* sourceFile, //throw ComError } //schedule file copy operation - ZEN_CHECK_COM(fileOp->CopyItem(psiSourceFile.get(), psiTargetFolder.get(), targetFileNameShort.c_str(), nullptr)); + ZEN_COM_CHECK(fileOp->CopyItem(psiSourceFile.get(), psiTargetFolder.get(), targetFileNameShort.c_str(), nullptr)); //perform actual operations - ZEN_CHECK_COM(fileOp->PerformOperations()); + ZEN_COM_CHECK(fileOp->PerformOperations()); //check if errors occured: if FOFX_EARLYFAILURE is not used, PerformOperations() can return with success despite errors! BOOL pfAnyOperationsAborted = FALSE; - ZEN_CHECK_COM(fileOp->GetAnyOperationsAborted(&pfAnyOperationsAborted)); + ZEN_COM_CHECK(fileOp->GetAnyOperationsAborted(&pfAnyOperationsAborted)); if (pfAnyOperationsAborted == TRUE) throw ComError(L"Operation did not complete successfully."); @@ -332,10 +332,10 @@ void copyFile(const wchar_t* sourceFile, //throw ComError void getFolderClsid(const wchar_t* dirname, CLSID& pathCLSID) //throw ComError { ComPtr<IShellFolder> desktopFolder; - ZEN_CHECK_COM(::SHGetDesktopFolder(desktopFolder.init())); //throw ComError + ZEN_COM_CHECK(::SHGetDesktopFolder(desktopFolder.init())); //throw ComError PIDLIST_RELATIVE pidlFolder = nullptr; - ZEN_CHECK_COM(desktopFolder->ParseDisplayName(nullptr, // [in] HWND hwnd, + ZEN_COM_CHECK(desktopFolder->ParseDisplayName(nullptr, // [in] HWND hwnd, nullptr, // [in] IBindCtx *pbc, const_cast<LPWSTR>(dirname), // [in] LPWSTR pszDisplayName, nullptr, // [out] ULONG *pchEaten, @@ -344,11 +344,11 @@ void getFolderClsid(const wchar_t* dirname, CLSID& pathCLSID) //throw ComError ZEN_ON_SCOPE_EXIT(::ILFree(pidlFolder)); //older version: ::CoTaskMemFree ComPtr<IPersist> persistFolder; - ZEN_CHECK_COM(desktopFolder->BindToObject(pidlFolder, // [in] PCUIDLIST_RELATIVE pidl, + ZEN_COM_CHECK(desktopFolder->BindToObject(pidlFolder, // [in] PCUIDLIST_RELATIVE pidl, nullptr, // [in] IBindCtx *pbc, IID_PPV_ARGS(persistFolder.init()))); //throw ComError - ZEN_CHECK_COM(persistFolder->GetClassID(&pathCLSID)); //throw ComError + ZEN_COM_CHECK(persistFolder->GetClassID(&pathCLSID)); //throw ComError } |