From c0fce877c478ddbf71a1b651c789e5ea00a00144 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:05:30 +0200 Subject: 3.4 --- library/Recycler/Recycler_Vista.vcproj | 409 --------------------------------- library/Recycler/dllmain.cpp | 22 -- library/Recycler/recycler.cpp | 142 ------------ library/Recycler/recycler.h | 24 -- 4 files changed, 597 deletions(-) delete mode 100644 library/Recycler/Recycler_Vista.vcproj delete mode 100644 library/Recycler/dllmain.cpp delete mode 100644 library/Recycler/recycler.cpp delete mode 100644 library/Recycler/recycler.h (limited to 'library/Recycler') diff --git a/library/Recycler/Recycler_Vista.vcproj b/library/Recycler/Recycler_Vista.vcproj deleted file mode 100644 index 65ab6609..00000000 --- a/library/Recycler/Recycler_Vista.vcproj +++ /dev/null @@ -1,409 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/library/Recycler/dllmain.cpp b/library/Recycler/dllmain.cpp deleted file mode 100644 index 834b4f88..00000000 --- a/library/Recycler/dllmain.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// dllmain.cpp : Definiert den Einstiegspunkt für die DLL-Anwendung. - -#define WIN32_LEAN_AND_MEAN -#include - - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - diff --git a/library/Recycler/recycler.cpp b/library/Recycler/recycler.cpp deleted file mode 100644 index b551d4d0..00000000 --- a/library/Recycler/recycler.cpp +++ /dev/null @@ -1,142 +0,0 @@ -#include "recycler.h" - -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#include // Included for shell constants such as FO_* values -#include // Required for necessary shell dependencies - -#include -#include -#include -#include - - -void writeString(const wchar_t* input, wchar_t* output, size_t outputBufferLen) -{ - const size_t newSize = min(wcslen(input) + 1, outputBufferLen); //including null-termination - memcpy(output, input, newSize * sizeof(wchar_t)); - output[newSize-1] = 0; //if output buffer is too small... -} - - -std::wstring numberToHexString(const long number) -{ - wchar_t result[100]; - swprintf(result, 100, L"0x%08x", number); - return std::wstring(result); -} - - -void writeErrorMsg(const wchar_t* input, HRESULT hr, wchar_t* output, size_t outputBufferLen) -{ - std::wstring formattedMsg(input); - formattedMsg += L" ("; - formattedMsg += numberToHexString(hr); - formattedMsg += L": "; - formattedMsg += _com_error(hr).ErrorMessage(); - formattedMsg += L")"; - - writeString(formattedMsg.c_str(), output, outputBufferLen); -} - - -//IShellItem resource management -template -class ReleaseAtExit -{ -public: - ReleaseAtExit(T*& item) : item_(item) {} - ~ReleaseAtExit() - { - if (item_ != NULL) - item_->Release(); - } -private: - T*& item_; -}; - - -bool Utility::moveToRecycleBin(const wchar_t* fileNames[], - size_t fileNo, //size of fileNames array - wchar_t* errorMessage, - size_t errorBufferLen) -{ - HRESULT hr; - - // Create the IFileOperation interface - IFileOperation* pfo = NULL; - ReleaseAtExit dummy(pfo); - hr = CoCreateInstance(CLSID_FileOperation, - NULL, - CLSCTX_ALL, - IID_PPV_ARGS(&pfo)); - if (FAILED(hr)) - { - writeErrorMsg(L"Error calling \"CoCreateInstance\".", hr, errorMessage, errorBufferLen); - return false; - } - - // Set the operation flags. Turn off all UI - // from being shown to the user during the - // operation. This includes error, confirmation - // and progress dialogs. - hr = pfo->SetOperationFlags(FOF_ALLOWUNDO | - FOF_NOCONFIRMATION | - FOF_SILENT | - FOF_NOERRORUI); - if (FAILED(hr)) - { - writeErrorMsg(L"Error calling \"SetOperationFlags\".", hr, errorMessage, errorBufferLen); - return false; - } - - for (size_t i = 0; i < fileNo; ++i) - { - //create file/folder item object - IShellItem* psiFile = NULL; - ReleaseAtExit dummy2(psiFile); - hr = SHCreateItemFromParsingName(fileNames[i], - NULL, - IID_PPV_ARGS(&psiFile)); - if (FAILED(hr)) - { - std::wstring message(L"Error calling \"SHCreateItemFromParsingName\" for file "); - message += std::wstring(L"\"") + fileNames[i] + L"\"."; - writeErrorMsg(message.c_str(), hr, errorMessage, errorBufferLen); - return false; - } - - hr = pfo->DeleteItem(psiFile, NULL); - if (FAILED(hr)) - { - writeErrorMsg(L"Error calling \"DeleteItem\".", hr, errorMessage, errorBufferLen); - return false; - } - } - - //perform actual operations - hr = pfo->PerformOperations(); - if (FAILED(hr)) - { - writeErrorMsg(L"Error calling \"PerformOperations\".", hr, errorMessage, errorBufferLen); - return false; - } - - //check if errors occured: if FOFX_EARLYFAILURE is not used, PerformOperations() can return with success despite errors! - BOOL pfAnyOperationsAborted = FALSE; - hr = pfo->GetAnyOperationsAborted(&pfAnyOperationsAborted); - if (FAILED(hr)) - { - writeErrorMsg(L"Error calling \"GetAnyOperationsAborted\".", hr, errorMessage, errorBufferLen); - return false; - } - - - if (pfAnyOperationsAborted == TRUE) - { - writeString(L"Operation did not complete successfully.", errorMessage, errorBufferLen); - return false; - } - - return true; -} diff --git a/library/Recycler/recycler.h b/library/Recycler/recycler.h deleted file mode 100644 index 59bec9dc..00000000 --- a/library/Recycler/recycler.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef RECYCLER_DLL_H -#define RECYCLER_DLL_H - -#ifdef RECYCLER_DLL_EXPORTS -#define RECYCLER_DLL_API extern "C" __declspec(dllexport) -#else -#define RECYCLER_DLL_API extern "C" __declspec(dllimport) -#endif - - -namespace Utility -{ -//COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize - -RECYCLER_DLL_API -bool moveToRecycleBin(const wchar_t* fileNames[], - size_t fileNo, //size of fileNames array - wchar_t* errorMessage, - size_t errorBufferLen); -} - - - -#endif //RECYCLER_DLL_H -- cgit