diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:10:11 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:10:11 +0200 |
commit | c0cdb2ad99a1e2a6ade5ce76c91177a79258e669 (patch) | |
tree | 4701a015385d9a6a5a4ba99a8f1f5d400fff26b1 /shared/IFileOperation | |
parent | 3.13 (diff) | |
download | FreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.tar.gz FreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.tar.bz2 FreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.zip |
3.14
Diffstat (limited to 'shared/IFileOperation')
-rw-r--r-- | shared/IFileOperation/dll_main.cpp | 10 | ||||
-rw-r--r-- | shared/IFileOperation/file_op.cpp | 32 | ||||
-rw-r--r-- | shared/IFileOperation/file_op.h | 14 |
3 files changed, 34 insertions, 22 deletions
diff --git a/shared/IFileOperation/dll_main.cpp b/shared/IFileOperation/dll_main.cpp index d23e5c48..ab387012 100644 --- a/shared/IFileOperation/dll_main.cpp +++ b/shared/IFileOperation/dll_main.cpp @@ -15,11 +15,11 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, { switch (fdwReason) { - case DLL_PROCESS_ATTACH: - case DLL_PROCESS_DETACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - break; + case DLL_PROCESS_ATTACH: + case DLL_PROCESS_DETACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; } return TRUE; } 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"); diff --git a/shared/IFileOperation/file_op.h b/shared/IFileOperation/file_op.h index 9842f0d6..a7b0434f 100644 --- a/shared/IFileOperation/file_op.h +++ b/shared/IFileOperation/file_op.h @@ -16,6 +16,10 @@ namespace fileop { +/*-------------- + |declarations| + --------------*/ + //COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize FILE_OP_DLL_API @@ -30,13 +34,17 @@ bool copyFile(const wchar_t* sourceFile, FILE_OP_DLL_API void getLastError(wchar_t* errorMessage, size_t errorBufferLen); - -//function typedefs +/*---------- + |typedefs| + ----------*/ typedef bool (*MoveToRecycleBinFct)(const wchar_t* fileNames[], size_t fileNo); typedef bool (*CopyFileFct)(const wchar_t* sourceFile, const wchar_t* targetFile); typedef void (*GetLastErrorFct)(wchar_t* errorMessage, size_t errorBufferLen); -//function names (use const pointers to ensure internal linkage) +/*-------------- + |symbol names| + --------------*/ +//(use const pointers to ensure internal linkage) const char* const moveToRecycleBinFctName = "moveToRecycleBin"; const char* const copyFileFctName = "copyFile"; const char* const getLastErrorFctName = "getLastError"; |