summaryrefslogtreecommitdiff
path: root/shared/IFileOperation
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:14:37 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:14:37 +0200
commit8bf668665b107469086f16cb8ad23e47d479d2b4 (patch)
tree66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /shared/IFileOperation
parent3.21 (diff)
downloadFreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz
FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2
FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip
4.0
Diffstat (limited to 'shared/IFileOperation')
-rw-r--r--shared/IFileOperation/FileOperation_Vista.vcxproj6
-rw-r--r--shared/IFileOperation/file_op.cpp13
-rw-r--r--shared/IFileOperation/file_op.h7
3 files changed, 21 insertions, 5 deletions
diff --git a/shared/IFileOperation/FileOperation_Vista.vcxproj b/shared/IFileOperation/FileOperation_Vista.vcxproj
index 9f9a9c28..5de402f4 100644
--- a/shared/IFileOperation/FileOperation_Vista.vcxproj
+++ b/shared/IFileOperation/FileOperation_Vista.vcxproj
@@ -29,10 +29,12 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -63,10 +65,10 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir>
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))
diff --git a/shared/IFileOperation/file_op.h b/shared/IFileOperation/file_op.h
index c1bb26a2..dbe00196 100644
--- a/shared/IFileOperation/file_op.h
+++ b/shared/IFileOperation/file_op.h
@@ -13,6 +13,8 @@
#define FILE_OP_DLL_API extern "C" __declspec(dllimport)
#endif
+#include "../build_info.h"
+
namespace fileop
{
@@ -48,6 +50,11 @@ typedef void (*GetLastErrorFct)(wchar_t* errorMessage, size_t errorBufferLen);
const char moveToRecycleBinFctName[] = "moveToRecycleBin";
const char copyFileFctName[] = "copyFile";
const char getLastErrorFctName[] = "getLastError";
+
+/*---------------
+ |library names|
+ ---------------*/
+inline const wchar_t* getDllName() { return util::is64BitBuild ? L"FileOperation_x64.dll" : L"FileOperation_Win32.dll"; }
}
bgstack15