diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:07:15 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:07:15 +0200 |
commit | 8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395 (patch) | |
tree | 975c6e590c31e56007006a23e7b15d0245d75b08 /library | |
parent | 3.6 (diff) | |
download | FreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.tar.gz FreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.tar.bz2 FreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.zip |
3.7
Diffstat (limited to 'library')
26 files changed, 300 insertions, 2555 deletions
diff --git a/library/CustomGrid.cpp b/library/CustomGrid.cpp index e9fe9eb6..5fc993ce 100644 --- a/library/CustomGrid.cpp +++ b/library/CustomGrid.cpp @@ -31,7 +31,7 @@ using namespace FreeFileSync; -const unsigned int MIN_ROW_COUNT = 15; +const size_t MIN_ROW_COUNT = 15; //class containing pure grid data: basically the same as wxGridStringTable, but adds cell formatting @@ -81,7 +81,7 @@ public: virtual int GetNumberRows() { if (gridDataView) - return std::max(static_cast<unsigned int>(gridDataView->rowsOnView()), MIN_ROW_COUNT); + return static_cast<int>(std::max(gridDataView->rowsOnView(), MIN_ROW_COUNT)); else return 0; //grid is initialized with zero number of rows } @@ -188,7 +188,7 @@ public: } - const FileSystemObject* getRawData(const unsigned int row) const + const FileSystemObject* getRawData(size_t row) const { if (gridDataView) return gridDataView->getObject(row); //returns NULL if request is not valid or not data found @@ -239,16 +239,16 @@ public: } - xmlAccess::ColumnTypes getTypeAtPos(unsigned pos) const + xmlAccess::ColumnTypes getTypeAtPos(size_t pos) const { if (pos < columnPositions.size()) return columnPositions[pos]; else - return xmlAccess::ColumnTypes(1000); + return xmlAccess::DIRECTORY; } //get filename in order to retrieve the icon from it - virtual Zstring getIconFile(const unsigned int row) const = 0; //return "folder" if row points to a folder + virtual Zstring getIconFile(size_t row) const = 0; //return "folder" if row points to a folder protected: template <SelectedSide side> @@ -298,7 +298,7 @@ protected: case xmlAccess::SIZE: //file size return FreeFileSync::numberToWxString(fileObj->getFileSize<side>(), true); case xmlAccess::DATE: //date - return FreeFileSync::utcTimeToLocalString(fileObj->getLastWriteTime<side>(), fileObj->getFullName<side>()); + return FreeFileSync::utcTimeToLocalString(fileObj->getLastWriteTime<side>()); case xmlAccess::EXTENSION: //file extension return zToWx(fileObj->getExtension<side>()); } @@ -342,7 +342,7 @@ public: return CustomGridTableRim::GetValueSub<LEFT_SIDE>(row, col); } - virtual Zstring getIconFile(const unsigned int row) const //return "folder" if row points to a folder + virtual Zstring getIconFile(size_t row) const //return "folder" if row points to a folder { const FileSystemObject* fsObj = getRawData(row); if (fsObj && !fsObj->isEmpty<LEFT_SIDE>()) @@ -366,7 +366,7 @@ public: return CustomGridTableRim::GetValueSub<RIGHT_SIDE>(row, col); } - virtual Zstring getIconFile(const unsigned int row) const //return "folder" if row points to a folder + virtual Zstring getIconFile(size_t row) const //return "folder" if row points to a folder { const FileSystemObject* fsObj = getRawData(row); if (fsObj && !fsObj->isEmpty<RIGHT_SIDE>()) @@ -916,7 +916,7 @@ std::set<size_t> CustomGrid::getAllSelectedRows() const const wxGridCellCoordsArray singlySelected = this->GetSelectedCells(); if (!singlySelected.IsEmpty()) { - for (unsigned int k = 0; k < singlySelected.GetCount(); ++k) + for (size_t k = 0; k < singlySelected.GetCount(); ++k) output.insert(singlySelected[k].GetRow()); } @@ -1149,11 +1149,11 @@ xmlAccess::ColumnAttributes CustomGridRim::getColumnAttributes() xmlAccess::ColumnAttributes output; xmlAccess::ColumnAttrib newEntry; - for (unsigned int i = 0; i < columnSettings.size(); ++i) + for (size_t i = 0; i < columnSettings.size(); ++i) { newEntry = columnSettings[i]; if (newEntry.visible) - newEntry.width = GetColSize(i); //hidden columns are sorted to the end of vector! + newEntry.width = GetColSize(static_cast<int>(i)); //hidden columns are sorted to the end of vector! output.push_back(newEntry); } @@ -1182,7 +1182,7 @@ void CustomGridRim::setColumnAttributes(const xmlAccess::ColumnAttributes& attr) } else { - for (unsigned int i = 0; i < xmlAccess::COLUMN_TYPE_COUNT; ++i) + for (size_t i = 0; i < xmlAccess::COLUMN_TYPE_COUNT; ++i) { xmlAccess::ColumnAttrib newEntry; @@ -1199,17 +1199,17 @@ void CustomGridRim::setColumnAttributes(const xmlAccess::ColumnAttributes& attr) } std::sort(columnSettings.begin(), columnSettings.end(), xmlAccess::sortByType); - for (unsigned int i = 0; i < xmlAccess::COLUMN_TYPE_COUNT; ++i) //just be sure that each type exists only once + for (size_t i = 0; i < xmlAccess::COLUMN_TYPE_COUNT; ++i) //just be sure that each type exists only once columnSettings[i].type = static_cast<xmlAccess::ColumnTypes>(i); std::sort(columnSettings.begin(), columnSettings.end(), xmlAccess::sortByPositionOnly); - for (unsigned int i = 0; i < xmlAccess::COLUMN_TYPE_COUNT; ++i) //just be sure that positions are numbered correctly + for (size_t i = 0; i < xmlAccess::COLUMN_TYPE_COUNT; ++i) //just be sure that positions are numbered correctly columnSettings[i].position = i; } std::sort(columnSettings.begin(), columnSettings.end(), xmlAccess::sortByPositionAndVisibility); std::vector<xmlAccess::ColumnTypes> newPositions; - for (unsigned int i = 0; i < columnSettings.size() && columnSettings[i].visible; ++i) //hidden columns are sorted to the end of vector! + for (size_t i = 0; i < columnSettings.size() && columnSettings[i].visible; ++i) //hidden columns are sorted to the end of vector! newPositions.push_back(columnSettings[i].type); //set column positions @@ -1217,8 +1217,8 @@ void CustomGridRim::setColumnAttributes(const xmlAccess::ColumnAttributes& attr) getGridDataTable()->setupColumns(newPositions); //set column width (set them after setupColumns!) - for (unsigned int i = 0; i < newPositions.size(); ++i) - SetColSize(i, columnSettings[i].width); + for (size_t i = 0; i < newPositions.size(); ++i) + SetColSize(static_cast<int>(i), columnSettings[i].width); //-------------------------------------------------------------------------------------------------------- //set special alignment for column "size" @@ -1236,7 +1236,7 @@ void CustomGridRim::setColumnAttributes(const xmlAccess::ColumnAttributes& attr) } -xmlAccess::ColumnTypes CustomGridRim::getTypeAtPos(unsigned pos) const +xmlAccess::ColumnTypes CustomGridRim::getTypeAtPos(size_t pos) const { assert(getGridDataTable()); return getGridDataTable()->getTypeAtPos(pos); @@ -1379,7 +1379,7 @@ void CustomGridRim::getIconsToBeLoaded(std::vector<Zstring>& newLoad) //loads al const int totalRows = const_cast<CustomGridTableRim*>(gridDataTable)->GetNumberRows(); //loop over all visible rows - const int firstRow = rowsOnScreen.first; + const int firstRow = static_cast<int>(rowsOnScreen.first); const int lastRow = std::min(int(rowsOnScreen.second), totalRows - 1); const int rowNo = lastRow - firstRow + 1; diff --git a/library/CustomGrid.h b/library/CustomGrid.h index 35915811..5f1823c0 100644 --- a/library/CustomGrid.h +++ b/library/CustomGrid.h @@ -153,7 +153,7 @@ public: xmlAccess::ColumnAttributes getColumnAttributes(); void setColumnAttributes(const xmlAccess::ColumnAttributes& attr); - xmlAccess::ColumnTypes getTypeAtPos(unsigned pos) const; + xmlAccess::ColumnTypes getTypeAtPos(size_t pos) const; static wxString getTypeName(xmlAccess::ColumnTypes colType); void autoSizeColumns(); //performance optimized column resizer @@ -171,14 +171,14 @@ private: //asynchronous icon loading void getIconsToBeLoaded(std::vector<Zstring>& newLoad); //loads all (not yet) drawn icons - typedef unsigned int FromRow; - typedef unsigned int ToRow; + typedef size_t FromRow; + typedef size_t ToRow; typedef std::pair<FromRow, ToRow> VisibleRowRange; VisibleRowRange getVisibleRows(); - typedef unsigned int RowNumber; - typedef bool IconLoaded; + typedef size_t RowNumber; + typedef bool IconLoaded; typedef std::map<RowNumber, IconLoaded> LoadSuccess; LoadSuccess loadIconSuccess; //save status of last icon load when drawing on GUI diff --git a/library/Recycler_Vista/Recycler_Vista.vcproj b/library/Recycler_Vista/Recycler_Vista.vcproj deleted file mode 100644 index 65ab6609..00000000 --- a/library/Recycler_Vista/Recycler_Vista.vcproj +++ /dev/null @@ -1,409 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9,00" - Name="Vista Recycler" - ProjectGUID="{70394AEF-5897-4911-AFA1-82EAF0581EFA}" - RootNamespace="ShadowDll" - Keyword="Win32Proj" - TargetFrameworkVersion="196613" - > - <Platforms> - <Platform - Name="Win32" - /> - <Platform - Name="x64" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;RECYCLER_DLL_EXPORTS" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Recycler_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" - SubSystem="2" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Debug|x64" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TargetEnvironment="3" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;RECYCLER_DLL_EXPORTS" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Recycler_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" - SubSystem="2" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="17" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;RECYCLER_DLL_EXPORTS" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Recycler_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="false" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - LinkTimeCodeGeneration="1" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|x64" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TargetEnvironment="3" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;RECYCLER_DLL_EXPORTS" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Recycler_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="false" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - LinkTimeCodeGeneration="1" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="17" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Quelldateien" - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath=".\dllmain.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug|x64" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|x64" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - </File> - </Filter> - <Filter - Name="Headerdateien" - Filter="h;hpp;hxx;hm;inl;inc;xsd" - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" - > - <File - RelativePath=".\recycler.cpp" - > - </File> - <File - RelativePath=".\recycler.h" - > - </File> - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/library/Recycler_Vista/dllmain.cpp b/library/Recycler_Vista/dllmain.cpp deleted file mode 100644 index 7db39bff..00000000 --- a/library/Recycler_Vista/dllmain.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> - - -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_Vista/recycler.cpp b/library/Recycler_Vista/recycler.cpp deleted file mode 100644 index 7858267b..00000000 --- a/library/Recycler_Vista/recycler.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#include "recycler.h" - -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#include <Shellapi.h> // Included for shell constants such as FO_* values -#include <shobjidl.h> // Required for necessary shell dependencies - -#include <algorithm> -#include <string> -#include <cstdio> -#include <comdef.h> - - -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 T> -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<IFileOperation> 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<IShellItem> 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_Vista/recycler.h b/library/Recycler_Vista/recycler.h deleted file mode 100644 index 697221c3..00000000 --- a/library/Recycler_Vista/recycler.h +++ /dev/null @@ -1,30 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#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 diff --git a/library/ShadowCopy/Shadow_2003.vcproj b/library/ShadowCopy/Shadow_2003.vcproj deleted file mode 100644 index 49730440..00000000 --- a/library/ShadowCopy/Shadow_2003.vcproj +++ /dev/null @@ -1,413 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9,00" - Name="Server2003" - ProjectGUID="{2F2994D6-FB89-4BAA-A5DF-03BAF7337FF2}" - RootNamespace="ShadowDll" - Keyword="Win32Proj" - TargetFrameworkVersion="196613" - > - <Platforms> - <Platform - Name="Win32" - /> - <Platform - Name="x64" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" - SubSystem="2" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Debug|x64" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TargetEnvironment="3" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" - SubSystem="2" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="17" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="false" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - LinkTimeCodeGeneration="1" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|x64" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TargetEnvironment="3" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="false" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - LinkTimeCodeGeneration="1" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="17" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Quelldateien" - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath=".\dllmain.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug|x64" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|x64" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - </File> - <File - RelativePath=".\shadow.cpp" - > - </File> - </Filter> - <Filter - Name="Headerdateien" - Filter="h;hpp;hxx;hm;inl;inc;xsd" - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" - > - <File - RelativePath=".\shadow.h" - > - </File> - </Filter> - <File - RelativePath=".\Server 2003\lib\$(PlatformName)\vssapi.lib" - > - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/library/ShadowCopy/Shadow_XP.vcproj b/library/ShadowCopy/Shadow_XP.vcproj deleted file mode 100644 index 74b231de..00000000 --- a/library/ShadowCopy/Shadow_XP.vcproj +++ /dev/null @@ -1,413 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9,00" - Name="XP" - ProjectGUID="{70394AEF-5897-4911-AFA1-82EAF0581EFA}" - RootNamespace="ShadowDll" - Keyword="Win32Proj" - TargetFrameworkVersion="196613" - > - <Platforms> - <Platform - Name="Win32" - /> - <Platform - Name="x64" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" - SubSystem="2" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Debug|x64" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TargetEnvironment="3" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" - SubSystem="2" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="17" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="false" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - LinkTimeCodeGeneration="1" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|x64" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TargetEnvironment="3" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="false" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - LinkTimeCodeGeneration="1" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="17" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Quelldateien" - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath=".\dllmain.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug|x64" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|x64" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - </File> - <File - RelativePath=".\shadow.cpp" - > - </File> - </Filter> - <Filter - Name="Headerdateien" - Filter="h;hpp;hxx;hm;inl;inc;xsd" - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" - > - <File - RelativePath=".\shadow.h" - > - </File> - </Filter> - <File - RelativePath=".\XP\lib\$(PlatformName)\vssapi.lib" - > - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/library/ShadowCopy/dllmain.cpp b/library/ShadowCopy/dllmain.cpp deleted file mode 100644 index 7db39bff..00000000 --- a/library/ShadowCopy/dllmain.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> - - -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/ShadowCopy/shadow.cpp b/library/ShadowCopy/shadow.cpp deleted file mode 100644 index b15bd4f9..00000000 --- a/library/ShadowCopy/shadow.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#include "shadow.h" - -#define WIN32_LEAN_AND_MEAN -#include "windows.h" - -#ifdef USE_SHADOW_XP -#include "xp/inc/vss.h" -#include "xp/inc/vswriter.h" -#include "xp/inc/vsbackup.h" - -#elif defined USE_SHADOW_2003 -#include "Server 2003/inc/vss.h" -#include "Server 2003/inc/vswriter.h" -#include "Server 2003/inc/vsbackup.h" -#else -adapt! -#endif - -#include <algorithm> -#include <string> -#include <cstdio> -#include <comdef.h> - -//typedef GUID VSS_ID; - - -void writeString(const wchar_t* input, wchar_t* output, unsigned int 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, unsigned int 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); -} - - -bool shadow::createShadowCopy(const wchar_t* volumeName, - wchar_t* shadowVolName, - unsigned int shadowBufferLen, - void** backupHandle, - wchar_t* errorMessage, - unsigned int errorBufferLen) -{ - //MessageBox(0, L"backup err", L"", 0); */ - *backupHandle = NULL; - HRESULT hr = NULL; - - IVssBackupComponents* pBackupComponents = NULL; - if (FAILED(hr = CreateVssBackupComponents(&pBackupComponents))) - { - if (hr == E_ACCESSDENIED) - writeErrorMsg(L"The caller does not have sufficient backup privileges or is not an administrator.", hr, errorMessage, errorBufferLen); - else - writeErrorMsg(L"Error calling \"CreateVssBackupComponents\".", hr, errorMessage, errorBufferLen); - return false; - } - - - if (FAILED(hr = pBackupComponents->InitializeForBackup())) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"InitializeForBackup\".", hr, errorMessage, errorBufferLen); - return false; - } - - - IVssAsync* pWriteMetaData = NULL; - if (FAILED(hr = pBackupComponents->GatherWriterMetadata( &pWriteMetaData ))) - { //this can happen if XP-version of VSS is used on Windows Vista (which needs at least VSS-Server2003 build) - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"GatherWriterMetadata\".", hr, errorMessage, errorBufferLen); - return false; - } - - //wait for shadow copy writers to complete - hr = pWriteMetaData->Wait(); - if (SUCCEEDED(hr)) - pWriteMetaData->QueryStatus(&hr, NULL); //check if the async operation succeeded... - - pWriteMetaData->Release(); - if (FAILED(hr)) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"ppWriteMetaData->Wait\".", hr, errorMessage, errorBufferLen); - return false; - } - - - VSS_ID snapshotSetId = {0}; - if (FAILED(hr = pBackupComponents->StartSnapshotSet( &snapshotSetId ))) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"StartSnapshotSet\".", hr, errorMessage, errorBufferLen); - return false; - } - - - VSS_ID SnapShotId = {0}; - if (FAILED(hr = pBackupComponents->AddToSnapshotSet(const_cast<wchar_t*>(volumeName), GUID_NULL, &SnapShotId))) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"AddToSnapshotSet\".", hr, errorMessage, errorBufferLen); - return false; - } - - - if (FAILED(hr = pBackupComponents->SetBackupState( false, false, VSS_BT_FULL ))) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"SetBackupState\".", hr, errorMessage, errorBufferLen); - return false; - } - - - IVssAsync* pPrepare = NULL; - if (FAILED(hr = pBackupComponents->PrepareForBackup( &pPrepare ))) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"PrepareForBackup\".", hr, errorMessage, errorBufferLen); - return false; - } - - hr = pPrepare->Wait(); - if (SUCCEEDED(hr)) - pPrepare->QueryStatus(&hr, NULL); //check if the async operation succeeded... - - pPrepare->Release(); - if (FAILED(hr)) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"pPrepare->Wait\".", hr, errorMessage, errorBufferLen); - return false; - } - - - IVssAsync* pDoShadowCopy = NULL; - if (FAILED(hr = pBackupComponents->DoSnapshotSet( &pDoShadowCopy ))) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"DoSnapshotSet\".", hr, errorMessage, errorBufferLen); - return false; - } - - hr = pDoShadowCopy->Wait(); - if (SUCCEEDED(hr)) - pDoShadowCopy->QueryStatus(&hr, NULL); //check if the async operation succeeded... - - pDoShadowCopy->Release(); - if (FAILED(hr)) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"pPrepare->Wait\".", hr, errorMessage, errorBufferLen); - return false; - } - - VSS_SNAPSHOT_PROP props; - if (FAILED(hr = pBackupComponents->GetSnapshotProperties( SnapShotId, &props ))) - { - releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"Error calling \"GetSnapshotProperties\".", hr, errorMessage, errorBufferLen); - return false; - } - - //finally: write volume name of newly created shadow copy - writeString(props.m_pwszSnapshotDeviceObject, shadowVolName, shadowBufferLen); - - VssFreeSnapshotProperties(&props); - - *backupHandle = pBackupComponents; - - return true; -} - - -void shadow::releaseShadowCopy(void* backupHandle) -{ - if (backupHandle != NULL) - static_cast<IVssBackupComponents*>(backupHandle)->Release(); -} diff --git a/library/ShadowCopy/shadow.h b/library/ShadowCopy/shadow.h deleted file mode 100644 index cc82e8e0..00000000 --- a/library/ShadowCopy/shadow.h +++ /dev/null @@ -1,39 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#ifndef SHADOWCOPY_H -#define SHADOWCOPY_H - -#ifdef SHADOWDLL_EXPORTS -#define SHADOWDLL_API extern "C" __declspec(dllexport) -#else -#define SHADOWDLL_API extern "C" __declspec(dllimport) -#endif - - -namespace shadow -{ - //COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize - - - //volumeName must end with "\", while shadowVolName does not end with "\" - SHADOWDLL_API - bool createShadowCopy(const wchar_t* volumeName, - wchar_t* shadowVolName, - unsigned int shadowBufferLen, - void** backupHandle, - wchar_t* errorMessage, - unsigned int errorBufferLen); - - - //don't forget to release the backupHandle after shadow copy is not needed anymore! - SHADOWDLL_API - void releaseShadowCopy(void* backupHandle); -} - - - -#endif //SHADOWCOPY_H diff --git a/library/Taskbar_Seven/Taskbar_Seven.vcproj b/library/Taskbar_Seven/Taskbar_Seven.vcproj deleted file mode 100644 index bf8e0993..00000000 --- a/library/Taskbar_Seven/Taskbar_Seven.vcproj +++ /dev/null @@ -1,409 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9,00" - Name="Taskbar_Seven" - ProjectGUID="{70394AEF-5897-4911-AFA1-82EAF0581EFA}" - RootNamespace="ShadowDll" - Keyword="Win32Proj" - TargetFrameworkVersion="196613" - > - <Platforms> - <Platform - Name="Win32" - /> - <Platform - Name="x64" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;TASKBAR_SEVEN_DLL_EXPORTS" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Taskbar7_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" - SubSystem="2" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Debug|x64" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TargetEnvironment="3" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;TASKBAR_SEVEN_DLL_EXPORTS" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Taskbar7_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" - SubSystem="2" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="17" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;TASKBAR_SEVEN_DLL_EXPORTS" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Taskbar7_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="false" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - LinkTimeCodeGeneration="1" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|x64" - OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - BuildLogFile="$(IntDir)\Build.html" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TargetEnvironment="3" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;TASKBAR_SEVEN_DLL_EXPORTS" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - SuppressStartupBanner="false" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Taskbar7_$(PlatformName).dll" - LinkIncremental="1" - SuppressStartupBanner="false" - GenerateDebugInformation="false" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - LinkTimeCodeGeneration="1" - ProfileGuidedDatabase="" - ImportLibrary="$(IntDir)$(TargetName).lib" - TargetMachine="17" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Quelldateien" - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath=".\dllmain.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug|x64" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|x64" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - </File> - <File - RelativePath=".\taskbar.cpp" - > - </File> - </Filter> - <Filter - Name="Headerdateien" - Filter="h;hpp;hxx;hm;inl;inc;xsd" - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" - > - <File - RelativePath=".\taskbar.h" - > - </File> - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/library/Taskbar_Seven/dllmain.cpp b/library/Taskbar_Seven/dllmain.cpp deleted file mode 100644 index 7db39bff..00000000 --- a/library/Taskbar_Seven/dllmain.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> - - -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/Taskbar_Seven/taskbar.cpp b/library/Taskbar_Seven/taskbar.cpp deleted file mode 100644 index 4baf2392..00000000 --- a/library/Taskbar_Seven/taskbar.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#include "taskbar.h" - -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#include <ShObjIdl.h> - -#include <map> -#include <string> -#include <comdef.h> - - -namespace -{ -void writeString(const std::wstring& input, wchar_t* output, size_t outputBufferLen) -{ - const size_t newSize = min(input.length() + 1, outputBufferLen); //including null-termination - memcpy(output, input.c_str(), 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); -} - - -std::wstring writeErrorMsg(const wchar_t* input, HRESULT hr) -{ - std::wstring output(input); - output += L" ("; - output += numberToHexString(hr); - output += L": "; - output += _com_error(hr).ErrorMessage(); - output += L")"; - return output; -} - - -using TaskbarSeven::TBHandle; -typedef std::map<TBHandle, ITaskbarList3*> TaskBarHandleMap; - -TaskbarSeven::TBHandle generateHandle() -{ - static TBHandle handle = 0; - return ++handle; //don't return 0! 0 is reserved for indicating failure -} - -TaskBarHandleMap taskBarHandles; - -std::wstring lastErrorMessage; -} -//################################################################################################## - - -TaskbarSeven::TBHandle TaskbarSeven::init() //call on app initializaiton; returns handle -{ - ITaskbarList3* pto = NULL; - HRESULT hr = CoCreateInstance(CLSID_TaskbarList, - NULL, - CLSCTX_ALL, - IID_PPV_ARGS(&pto)); - if (FAILED(hr)) - { - lastErrorMessage = writeErrorMsg(L"Error calling \"CoCreateInstance\".", hr); - return 0; - } - - TBHandle newHandle = ::generateHandle(); - taskBarHandles[newHandle] = pto; - return newHandle; -} - - -void TaskbarSeven::release(TBHandle handle) //release handle on app exit -{ - TaskBarHandleMap::const_iterator iter = taskBarHandles.find(handle); - if (iter != taskBarHandles.end()) - { - if (iter->second != NULL) - iter->second->Release(); - taskBarHandles.erase(iter); - } -} - - -bool TaskbarSeven::setStatus(TBHandle handle, - void* hwnd, //HWND: window assciated to the taskbar icon - TaskBarStatus status) -{ - TBPFLAG flag = TBPF_NORMAL; - switch (status) - { - case STATUS_NOPROGRESS: - flag = TBPF_NOPROGRESS; - break; - case STATUS_INDETERMINATE: - flag = TBPF_INDETERMINATE; - break; - case STATUS_NORMAL: - flag = TBPF_NORMAL; - break; - case STATUS_ERROR: - flag = TBPF_ERROR; - break; - case STATUS_PAUSED: - flag = TBPF_PAUSED; - break; - } - - ITaskbarList3* pto = taskBarHandles[handle]; - if (pto) - { - HRESULT hr = pto->SetProgressState(static_cast<HWND>(hwnd), //[in] HWND hwnd, - flag); //[in] TBPFLAG tbpFlags - if (FAILED(hr)) - { - lastErrorMessage = writeErrorMsg(L"Error calling \"SetProgressState\".", hr); - return false; - } - } - return true; -} - - -bool TaskbarSeven::setProgress(TBHandle handle, - void* hwnd, //HWND: window assciated to the taskbar icon - size_t current, - size_t total) -{ - ITaskbarList3* pto = taskBarHandles[handle]; - - if (pto) - { - HRESULT hr = pto->SetProgressValue( - static_cast<HWND>(hwnd), //[in] HWND hwnd, - current, //[in] ULONGLONG ullCompleted, - total); //[in] ULONGLONG ullTotal - if (FAILED(hr)) - { - lastErrorMessage = writeErrorMsg(L"Error calling \"SetProgressValue\".", hr); - return false; - } - } - return true; -} - - -void TaskbarSeven::getLastError(wchar_t* errorMessage, size_t errorBufferLen) -{ - writeString(lastErrorMessage, errorMessage, errorBufferLen); -} diff --git a/library/Taskbar_Seven/taskbar.h b/library/Taskbar_Seven/taskbar.h deleted file mode 100644 index 835f02ec..00000000 --- a/library/Taskbar_Seven/taskbar.h +++ /dev/null @@ -1,62 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#ifndef TASKBAR_SEVEN_DLL_H -#define TASKBAR_SEVEN_DLL_H - -#ifdef TASKBAR_SEVEN_DLL_EXPORTS -#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllexport) -#else -#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport) -#endif - - -namespace TaskbarSeven -{ -enum TaskBarStatus -{ - STATUS_NOPROGRESS, - STATUS_INDETERMINATE, - STATUS_NORMAL, - STATUS_ERROR, - STATUS_PAUSED -}; - -typedef size_t TBHandle; - - -//COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize -DLL_FUNCTION_DECLARATION -TBHandle init(); //returns handle; 0 on failure - -DLL_FUNCTION_DECLARATION -void release(TBHandle handle); //release taskbar handle - -DLL_FUNCTION_DECLARATION -bool setStatus(TBHandle handle, - void* hwnd, //HWND: window assciated to the taskbar icon - TaskBarStatus status); - - -DLL_FUNCTION_DECLARATION -bool setProgress(TBHandle handle, - void* hwnd, //HWND: window assciated to the taskbar icon - size_t current, - size_t total); - -//if any of the functions above returns 'false', this message returns last error -void getLastError(wchar_t* errorMessage, size_t errorBufferLen); - - -//function typedefs -typedef TBHandle (*initFct)(); -typedef void (*releaseFct)(TBHandle handle); -typedef bool (*setStatusFct)(TBHandle handle, void* hwnd, TaskBarStatus status); -typedef bool (*setProgressFct)(TBHandle handle, void* hwnd, size_t current, size_t total); -typedef void (*getLastErrorFct)(wchar_t* errorMessage, size_t errorBufferLen); -} - -#endif //TASKBAR_SEVEN_DLL_H
\ No newline at end of file diff --git a/library/binary.cpp b/library/binary.cpp index 409b024a..8b8fd2ec 100644 --- a/library/binary.cpp +++ b/library/binary.cpp @@ -5,32 +5,122 @@ // ************************************************************************** // #include "binary.h" -#include <boost/scoped_array.hpp> #include "../shared/fileIO.h" +#include <vector> +#include <wx/stopwatch.h> -bool FreeFileSync::filesHaveSameContent(const Zstring& filename1, const Zstring& filename2, CompareCallback& callback) +inline +void setMinSize(std::vector<char>& buffer, size_t minSize) +{ + if (buffer.size() < minSize) //this is similar to reserve(), but be need a "properly initialized" array here + buffer.resize(minSize); +} + + +namespace { - const size_t BUFFER_SIZE = 512 * 1024; //512 kb seems to be the perfect buffer size - static boost::scoped_array<unsigned char> memory1(new unsigned char[BUFFER_SIZE]); - static boost::scoped_array<unsigned char> memory2(new unsigned char[BUFFER_SIZE]); +class BufferSize +{ +public: + BufferSize() : bufSize(BUFFER_SIZE_START) {} + + void inc() + { + if (bufSize < BUFFER_SIZE_MAX) + bufSize *= 2; + } + + void dec() + { + if (bufSize > BUFFER_SIZE_MIN) + bufSize /= 2; + } + + operator size_t() const + { + return bufSize; + } + +private: + static const size_t BUFFER_SIZE_MIN = 128 * 1024; + static const size_t BUFFER_SIZE_START = 512 * 1024; //512 kb seems to be a reasonable initial buffer size + static const size_t BUFFER_SIZE_MAX = 16 * 1024 * 1024; + + /*Tests on Win7 x64 show that buffer size does NOT matter if files are located on different physical disks! + Impact of buffer size when files are on same disk: + + buffer MB/s + ------------ + 64 10 + 128 19 + 512 40 + 1024 48 + 2048 56 + 4096 56 + 8192 56 + */ + size_t bufSize; +}; +} + + +bool FreeFileSync::filesHaveSameContent(const Zstring& filename1, const Zstring& filename2, CompareCallback& callback) +{ FileInput file1(filename1); //throw FileError() FileInput file2(filename2); //throw FileError() + BufferSize bufferSize; + + static std::vector<char> memory1; + static std::vector<char> memory2; + wxLongLong bytesCompared; + + wxLongLong lastDelayViolation = wxGetLocalTimeMillis(); + do { - const size_t length1 = file1.read(memory1.get(), BUFFER_SIZE); //returns actual number of bytes read; throw FileError() - const size_t length2 = file2.read(memory2.get(), BUFFER_SIZE); // + setMinSize(memory1, bufferSize); + setMinSize(memory2, bufferSize); - if (length1 != length2 || ::memcmp(memory1.get(), memory2.get(), length1) != 0) + const wxLongLong startTime = wxGetLocalTimeMillis(); + + const size_t length1 = file1.read(&memory1[0], bufferSize); //returns actual number of bytes read; throw FileError() + const size_t length2 = file2.read(&memory2[0], bufferSize); // + + const wxLongLong stopTime = wxGetLocalTimeMillis(); + + //-------- dynamically set buffer size to keep callback interval between 200 - 500ms --------------------- + const wxLongLong loopTime = stopTime - startTime; + if (loopTime < 200 && stopTime - lastDelayViolation > 2000) //avoid "flipping back": e.g. DVD-Roms read 32MB at once, so first read may be > 300 ms, but second one will be 0ms! + { + lastDelayViolation = stopTime; + bufferSize.inc(); //practically no costs! + } + else if (loopTime > 500) + { + lastDelayViolation = stopTime; + bufferSize.dec(); // + } + //------------------------------------------------------------------------------------------------ + +//#warning +// static wxLongLong blorg = wxGetLocalTimeMillis(); +// if (wxGetLocalTimeMillis() - blorg > 5000) +// { +// blorg = wxGetLocalTimeMillis(); +// wxMessageBox(numberToZstring<size_t>(bufferSize).c_str()); +// } + + + + if (length1 != length2 || ::memcmp(&memory1[0], &memory2[0], length1) != 0) return false; bytesCompared += length1 * 2; - - //send progress updates - callback.updateCompareStatus(bytesCompared); + callback.updateCompareStatus(bytesCompared); //send progress updates } while (!file1.eof()); diff --git a/library/dbFile.cpp b/library/dbFile.cpp index c08c8ae8..7a000197 100644 --- a/library/dbFile.cpp +++ b/library/dbFile.cpp @@ -15,6 +15,7 @@ #include <wx/mstream.h> #include "../shared/serialize.h" #include "../shared/fileIO.h" +#include "../shared/loki/ScopeGuard.h" #ifdef FFS_WIN #include <wx/msw/wrapwin.h> //includes "windows.h" @@ -173,7 +174,6 @@ DbStreamData loadFile(const Zstring& filename) //throw (FileError) _("One of the FreeFileSync database files is not yet existing:") + wxT(" \n") + wxT("\"") + zToWx(filename) + wxT("\"")); - //read format description (uncompressed) FileInputStreamDB uncompressed(filename); //throw (FileError) @@ -190,33 +190,40 @@ std::pair<DirInfoPtr, DirInfoPtr> FreeFileSync::loadFromDisk(const BaseDirMappin const Zstring fileNameLeft = baseMapping.getDBFilename<LEFT_SIDE>(); const Zstring fileNameRight = baseMapping.getDBFilename<RIGHT_SIDE>(); - //read file data: db ID + mapping of partner-ID/DirInfo-stream - const DbStreamData dbEntriesLeft = ::loadFile(fileNameLeft); - const DbStreamData dbEntriesRight = ::loadFile(fileNameRight); - - //find associated DirInfo-streams - DirectoryTOC::const_iterator dbLeft = dbEntriesLeft.second.find(dbEntriesRight.first); //find left db-entry that corresponds to right database - if (dbLeft == dbEntriesLeft.second.end()) - throw FileError(wxString(_("Initial synchronization:")) + wxT(" \n\n") + - _("One of the FreeFileSync database entries within the following file is not yet existing:") + wxT(" \n") + - wxT("\"") + zToWx(fileNameLeft) + wxT("\"")); - - DirectoryTOC::const_iterator dbRight = dbEntriesRight.second.find(dbEntriesLeft.first); //find left db-entry that corresponds to right database - if (dbRight == dbEntriesRight.second.end()) - throw FileError(wxString(_("Initial synchronization:")) + wxT(" \n\n") + - _("One of the FreeFileSync database entries within the following file is not yet existing:") + wxT(" \n") + - wxT("\"") + zToWx(fileNameRight) + wxT("\"")); - - //read streams into DirInfo - boost::shared_ptr<DirInformation> dirInfoLeft(new DirInformation); - wxMemoryInputStream buffer(&(*dbLeft->second)[0], dbLeft->second->size()); //convert char-array to inputstream: no copying, ownership not transferred - ReadDirInfo(buffer, zToWx(fileNameLeft), *dirInfoLeft); //read file/dir information - - boost::shared_ptr<DirInformation> dirInfoRight(new DirInformation); - wxMemoryInputStream buffer2(&(*dbRight->second)[0], dbRight->second->size()); //convert char-array to inputstream: no copying, ownership not transferred - ReadDirInfo(buffer2, zToWx(fileNameRight), *dirInfoRight); //read file/dir information - - return std::make_pair(dirInfoLeft, dirInfoRight); + try + { + //read file data: db ID + mapping of partner-ID/DirInfo-stream + const DbStreamData dbEntriesLeft = ::loadFile(fileNameLeft); + const DbStreamData dbEntriesRight = ::loadFile(fileNameRight); + + //find associated DirInfo-streams + DirectoryTOC::const_iterator dbLeft = dbEntriesLeft.second.find(dbEntriesRight.first); //find left db-entry that corresponds to right database + if (dbLeft == dbEntriesLeft.second.end()) + throw FileError(wxString(_("Initial synchronization:")) + wxT(" \n\n") + + _("One of the FreeFileSync database entries within the following file is not yet existing:") + wxT(" \n") + + wxT("\"") + zToWx(fileNameLeft) + wxT("\"")); + + DirectoryTOC::const_iterator dbRight = dbEntriesRight.second.find(dbEntriesLeft.first); //find left db-entry that corresponds to right database + if (dbRight == dbEntriesRight.second.end()) + throw FileError(wxString(_("Initial synchronization:")) + wxT(" \n\n") + + _("One of the FreeFileSync database entries within the following file is not yet existing:") + wxT(" \n") + + wxT("\"") + zToWx(fileNameRight) + wxT("\"")); + + //read streams into DirInfo + boost::shared_ptr<DirInformation> dirInfoLeft(new DirInformation); + wxMemoryInputStream buffer(&(*dbLeft->second)[0], dbLeft->second->size()); //convert char-array to inputstream: no copying, ownership not transferred + ReadDirInfo(buffer, zToWx(fileNameLeft), *dirInfoLeft); //read file/dir information + + boost::shared_ptr<DirInformation> dirInfoRight(new DirInformation); + wxMemoryInputStream buffer2(&(*dbRight->second)[0], dbRight->second->size()); //convert char-array to inputstream: no copying, ownership not transferred + ReadDirInfo(buffer2, zToWx(fileNameRight), *dirInfoRight); //read file/dir information + + return std::make_pair(dirInfoLeft, dirInfoRight); + } + catch (const std::bad_alloc&) //this is most likely caused by a corrupted database file + { + throw FileError(wxString(_("Error reading from synchronization database:")) + wxT(" (bad_alloc)")); + } } @@ -346,74 +353,75 @@ void FreeFileSync::saveToDisk(const BaseDirMapping& baseMapping) //throw (FileEr removeFile(fileNameLeftTmp); removeFile(fileNameRightTmp); - try - { - //load old database files... - - //read file data: db ID + mapping of partner-ID/DirInfo-stream: may throw! - DbStreamData dbEntriesLeft; - if (FreeFileSync::fileExists(baseMapping.getDBFilename<LEFT_SIDE>())) - try - { - dbEntriesLeft = ::loadFile(baseMapping.getDBFilename<LEFT_SIDE>()); - } - catch(FileError&) {} //if error occurs: just overwrite old file! User is informed about issues right after comparing! - //else -> dbEntriesLeft has empty mapping, but already a DB-ID! - - //read file data: db ID + mapping of partner-ID/DirInfo-stream: may throw! - DbStreamData dbEntriesRight; - if (FreeFileSync::fileExists(baseMapping.getDBFilename<RIGHT_SIDE>())) - try - { - dbEntriesRight = ::loadFile(baseMapping.getDBFilename<RIGHT_SIDE>()); - } - catch(FileError&) {} //if error occurs: just overwrite old file! User is informed about issues right after comparing! + //load old database files... - //create new database entries - MemoryStreamPtr dbEntryLeft(new std::vector<char>); + //read file data: db ID + mapping of partner-ID/DirInfo-stream: may throw! + DbStreamData dbEntriesLeft; + if (FreeFileSync::fileExists(baseMapping.getDBFilename<LEFT_SIDE>())) + try { - wxMemoryOutputStream buffer; - SaveDirInfo<LEFT_SIDE>(baseMapping, zToWx(baseMapping.getDBFilename<LEFT_SIDE>()), buffer); - dbEntryLeft->resize(buffer.GetSize()); //convert output stream to char-array - buffer.CopyTo(&(*dbEntryLeft)[0], buffer.GetSize()); // + dbEntriesLeft = ::loadFile(baseMapping.getDBFilename<LEFT_SIDE>()); } + catch(FileError&) {} //if error occurs: just overwrite old file! User is already informed about issues right after comparing! + //else -> dbEntriesLeft has empty mapping, but already a DB-ID! - MemoryStreamPtr dbEntryRight(new std::vector<char>); + //read file data: db ID + mapping of partner-ID/DirInfo-stream: may throw! + DbStreamData dbEntriesRight; + if (FreeFileSync::fileExists(baseMapping.getDBFilename<RIGHT_SIDE>())) + try { - wxMemoryOutputStream buffer; - SaveDirInfo<RIGHT_SIDE>(baseMapping, zToWx(baseMapping.getDBFilename<RIGHT_SIDE>()), buffer); - dbEntryRight->resize(buffer.GetSize()); //convert output stream to char-array - buffer.CopyTo(&(*dbEntryRight)[0], buffer.GetSize()); // + dbEntriesRight = ::loadFile(baseMapping.getDBFilename<RIGHT_SIDE>()); } + catch(FileError&) {} //if error occurs: just overwrite old file! User is already informed about issues right after comparing! - //create/update DirInfo-streams - dbEntriesLeft.second[dbEntriesRight.first] = dbEntryLeft; - dbEntriesRight.second[dbEntriesLeft.first] = dbEntryRight; - - //write (temp-) files... - saveFile(dbEntriesLeft, fileNameLeftTmp); //throw (FileError) - saveFile(dbEntriesRight, fileNameRightTmp); //throw (FileError) + //create new database entries + MemoryStreamPtr dbEntryLeft(new std::vector<char>); + { + wxMemoryOutputStream buffer; + SaveDirInfo<LEFT_SIDE>(baseMapping, zToWx(baseMapping.getDBFilename<LEFT_SIDE>()), buffer); + dbEntryLeft->resize(buffer.GetSize()); //convert output stream to char-array + buffer.CopyTo(&(*dbEntryLeft)[0], buffer.GetSize()); // + } - //operation finished: rename temp files -> this should work transactionally: - //if there were no write access, creation of temp files would have failed - removeFile(baseMapping.getDBFilename<LEFT_SIDE>()); - removeFile(baseMapping.getDBFilename<RIGHT_SIDE>()); - renameFile(fileNameLeftTmp, baseMapping.getDBFilename<LEFT_SIDE>()); //throw (FileError); - renameFile(fileNameRightTmp, baseMapping.getDBFilename<RIGHT_SIDE>()); //throw (FileError); + MemoryStreamPtr dbEntryRight(new std::vector<char>); + { + wxMemoryOutputStream buffer; + SaveDirInfo<RIGHT_SIDE>(baseMapping, zToWx(baseMapping.getDBFilename<RIGHT_SIDE>()), buffer); + dbEntryRight->resize(buffer.GetSize()); //convert output stream to char-array + buffer.CopyTo(&(*dbEntryRight)[0], buffer.GetSize()); // } - catch (...) + + //create/update DirInfo-streams + dbEntriesLeft.second[dbEntriesRight.first] = dbEntryLeft; + dbEntriesRight.second[dbEntriesLeft.first] = dbEntryRight; + + + struct TryCleanUp //ensure cleanup if working with temporary failed! { - try //clean up: (try to) delete old tmp files + static void tryDeleteFile(const Zstring& filename) //throw () { - removeFile(fileNameLeftTmp); - } - catch (...) {} - try - { - removeFile(fileNameRightTmp); + try + { + removeFile(filename); + } + catch (...) {} } - catch (...) {} + }; - throw; - } + //write (temp-) files... + Loki::ScopeGuard guardTempFileLeft = Loki::MakeGuard(&TryCleanUp::tryDeleteFile, fileNameLeftTmp); + saveFile(dbEntriesLeft, fileNameLeftTmp); //throw (FileError) + + Loki::ScopeGuard guardTempFileRight = Loki::MakeGuard(&TryCleanUp::tryDeleteFile, fileNameRightTmp); + saveFile(dbEntriesRight, fileNameRightTmp); //throw (FileError) + + //operation finished: rename temp files -> this should work transactionally: + //if there were no write access, creation of temp files would have failed + removeFile(baseMapping.getDBFilename<LEFT_SIDE>()); + removeFile(baseMapping.getDBFilename<RIGHT_SIDE>()); + renameFile(fileNameLeftTmp, baseMapping.getDBFilename<LEFT_SIDE>()); //throw (FileError); + renameFile(fileNameRightTmp, baseMapping.getDBFilename<RIGHT_SIDE>()); //throw (FileError); + + guardTempFileLeft.Dismiss(); //no need to delete temp file anymore + guardTempFileRight.Dismiss(); // } diff --git a/library/filter.cpp b/library/filter.cpp index d7f12bec..931532c3 100644 --- a/library/filter.cpp +++ b/library/filter.cpp @@ -127,28 +127,28 @@ void addFilterEntry(const Zstring& filtername, std::set<Zstring>& fileFilter, st } -class MatchFound : public std::unary_function<const DefaultChar*, bool> +class MatchFound : public std::unary_function<Zstring, bool> { public: - MatchFound(const DefaultChar* name) : name_(name) {} + MatchFound(const Zstring& name) : name_(name) {} - bool operator()(const DefaultChar* mask) const + bool operator()(const Zstring& mask) const { - return Zstring::Matches(name_, mask); + return Zstring::Matches(name_.c_str(), mask.c_str()); } private: - const DefaultChar* name_; + const Zstring& name_; }; inline -bool matchesFilter(const DefaultChar* name, const std::set<Zstring>& filter) +bool matchesFilter(const Zstring& name, const std::set<Zstring>& filter) { #ifdef FFS_WIN //Windows does NOT distinguish between upper/lower-case Zstring nameFormatted = name; nameFormatted.MakeUpper(); #elif defined FFS_LINUX //Linux DOES distinguish between upper/lower-case - const DefaultChar* const nameFormatted = name; //nothing to do here + const Zstring& nameFormatted = name; //nothing to do here #endif return std::find_if(filter.begin(), filter.end(), MatchFound(nameFormatted)) != filter.end(); @@ -182,17 +182,17 @@ bool matchesMaskBegin(const DefaultChar* string, const DefaultChar* mask) inline -bool matchesFilterBegin(const DefaultChar* name, const std::set<Zstring>& filter) +bool matchesFilterBegin(const Zstring& name, const std::set<Zstring>& filter) { #ifdef FFS_WIN //Windows does NOT distinguish between upper/lower-case Zstring nameFormatted = name; nameFormatted.MakeUpper(); #elif defined FFS_LINUX //Linux DOES distinguish between upper/lower-case - const DefaultChar* const nameFormatted = name; //nothing to do here + const Zstring& nameFormatted = name; //nothing to do here #endif return std::find_if(filter.begin(), filter.end(), - boost::bind(matchesMaskBegin, nameFormatted, _1)) != filter.end(); + boost::bind(matchesMaskBegin, nameFormatted.c_str(), _1)) != filter.end(); } @@ -229,14 +229,14 @@ NameFilter::NameFilter(const Zstring& includeFilter, const Zstring& excludeFilte } -bool NameFilter::passFileFilter(const DefaultChar* relFilename) const +bool NameFilter::passFileFilter(const Zstring& relFilename) const { return matchesFilter(relFilename, filterFileIn) && //process include filters !matchesFilter(relFilename, filterFileEx); //process exclude filters } -bool NameFilter::passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const +bool NameFilter::passDirFilter(const Zstring& relDirname, bool* subObjMightMatch) const { assert(subObjMightMatch == NULL || *subObjMightMatch == true); //check correct usage @@ -251,7 +251,7 @@ bool NameFilter::passDirFilter(const DefaultChar* relDirname, bool* subObjMightM { if (subObjMightMatch) { - Zstring subNameBegin(relDirname); + Zstring subNameBegin = relDirname; subNameBegin += globalFunctions::FILE_NAME_SEPARATOR; *subObjMightMatch = matchesFilterBegin(subNameBegin, filterFileIn) || //might match a file in subdirectory diff --git a/library/filter.h b/library/filter.h index 5df74997..f27e06e6 100644 --- a/library/filter.h +++ b/library/filter.h @@ -36,8 +36,8 @@ public: virtual ~BaseFilter() {} //filtering - virtual bool passFileFilter(const DefaultChar* relFilename) const = 0; - virtual bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const = 0; + virtual bool passFileFilter(const Zstring& relFilename) const = 0; + virtual bool passDirFilter(const Zstring& relDirname, bool* subObjMightMatch) const = 0; //subObjMightMatch: file/dir in subdirectories could(!) match //note: variable is only set if passDirFilter returns false! @@ -65,8 +65,8 @@ class NullFilter : public BaseFilter //no filtering at all { public: static FilterRef load(wxInputStream& stream); //"serial constructor" - virtual bool passFileFilter(const DefaultChar* relFilename) const; - virtual bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const; + virtual bool passFileFilter(const Zstring& relFilename) const; + virtual bool passDirFilter(const Zstring& relDirname, bool* subObjMightMatch) const; virtual bool isNull() const; private: @@ -82,8 +82,8 @@ public: NameFilter(const Zstring& includeFilter, const Zstring& excludeFilter); static FilterRef load(wxInputStream& stream); //"serial constructor" - virtual bool passFileFilter(const DefaultChar* relFilename) const; - virtual bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const; + virtual bool passFileFilter(const Zstring& relFilename) const; + virtual bool passDirFilter(const Zstring& relDirname, bool* subObjMightMatch) const; virtual bool isNull() const; private: @@ -107,8 +107,8 @@ public: CombinedFilter(const FilterRef& first, const FilterRef& second) : first_(first), second_(second) {} static FilterRef load(wxInputStream& stream); //"serial constructor" - virtual bool passFileFilter(const DefaultChar* relFilename) const; - virtual bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const; + virtual bool passFileFilter(const Zstring& relFilename) const; + virtual bool passDirFilter(const Zstring& relDirname, bool* subObjMightMatch) const; virtual bool isNull() const; private: @@ -151,14 +151,14 @@ BaseFilter::FilterRef NullFilter::load(wxInputStream& stream) //"serial construc inline -bool NullFilter::passFileFilter(const DefaultChar* relFilename) const +bool NullFilter::passFileFilter(const Zstring& relFilename) const { return true; } inline -bool NullFilter::passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const +bool NullFilter::passDirFilter(const Zstring& relDirname, bool* subObjMightMatch) const { assert(subObjMightMatch == NULL || *subObjMightMatch == true); //check correct usage return true; @@ -188,7 +188,7 @@ Zstring NullFilter::uniqueClassIdentifier() const inline -bool CombinedFilter::passFileFilter(const DefaultChar* relFilename) const +bool CombinedFilter::passFileFilter(const Zstring& relFilename) const { return first_->passFileFilter(relFilename) && //short-circuit behavior second_->passFileFilter(relFilename); @@ -196,7 +196,7 @@ bool CombinedFilter::passFileFilter(const DefaultChar* relFilename) const inline -bool CombinedFilter::passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const +bool CombinedFilter::passDirFilter(const Zstring& relDirname, bool* subObjMightMatch) const { return first_->passDirFilter(relDirname, subObjMightMatch) && //short-circuit behavior: subObjMightMatch handled correctly! second_->passDirFilter(relDirname, subObjMightMatch); diff --git a/library/pch.h b/library/pch.h index 44a3b574..1fb71f00 100644 --- a/library/pch.h +++ b/library/pch.h @@ -33,10 +33,8 @@ do NOT use in release build! #include <map> #include <memory> #include <fstream> - -#ifdef FFS_LINUX -#include <utime.h> -#endif //FFS_LINUX +#include <sstream> +#include <new> //other wxWidgets headers #include <wx/log.h> diff --git a/library/processXml.cpp b/library/processXml.cpp index 1cc279b0..4ecc0350 100644 --- a/library/processXml.cpp +++ b/library/processXml.cpp @@ -302,8 +302,11 @@ void FfsXmlParser::readXmlMainConfig(MainConfiguration& mainCfg) //max. allowed file time deviation readXmlElementLogging("FileTimeTolerance", cmpSettings, mainCfg.hidden.fileTimeTolerance); + //include symbolic links at all? + readXmlElementLogging("IncludeSymlinks", cmpSettings, mainCfg.processSymlinks); + //traverse into symbolic links (to folders) - readXmlElementLogging("TraverseDirectorySymlinks", cmpSettings, mainCfg.hidden.traverseDirectorySymlinks); + readXmlElementLogging("TraverseDirectorySymlinks", cmpSettings, mainCfg.traverseDirectorySymlinks); //########################################################### const TiXmlElement* syncCfg = hRoot.FirstChild("MainConfig").FirstChild("Synchronization").ToElement(); @@ -322,7 +325,7 @@ void FfsXmlParser::readXmlMainConfig(MainConfiguration& mainCfg) const TiXmlElement* syncConfig = hRoot.FirstChild("MainConfig").FirstChild("Synchronization").ToElement(); //copy symbolic links to files - readXmlElementLogging("CopyFileSymlinks", syncConfig, mainCfg.hidden.copyFileSymlinks); + readXmlElementLogging("CopyFileSymlinks", syncConfig, mainCfg.copyFileSymlinks); //verify file copying readXmlElementLogging("VerifyCopiedFiles", syncConfig, mainCfg.hidden.verifyFileCopy); @@ -337,9 +340,12 @@ void FfsXmlParser::readXmlMainConfig(MainConfiguration& mainCfg) const TiXmlElement* filter = TiXmlHandleConst(miscSettings).FirstChild("Filter").ToElement(); //read filter settings - readXmlElementLogging("Active", filter, mainCfg.filterIsActive); - readXmlElementLogging("Include", filter, mainCfg.includeFilter); - readXmlElementLogging("Exclude", filter, mainCfg.excludeFilter); + Zstring includeFilter; + Zstring excludeFilter; + readXmlElementLogging("Include", filter, includeFilter); + readXmlElementLogging("Exclude", filter, excludeFilter); + + mainCfg.globalFilter = FilterConfig(includeFilter, excludeFilter); //########################################################### const TiXmlElement* pairs = hRoot.FirstChild("MainConfig").FirstChild("FolderPairs").FirstChild("Pair").ToElement(); @@ -375,7 +381,7 @@ void FfsXmlParser::readXmlGuiConfig(xmlAccess::XmlGuiConfig& outputCfg) readXmlElementLogging("HideFiltered", guiConfig, outputCfg.hideFilteredElements); - xmlAccess::OnError errorHand; + xmlAccess::OnError errorHand = ON_ERROR_POPUP; readXmlElementLogging("HandleError", guiConfig, errorHand); outputCfg.ignoreErrors = errorHand == xmlAccess::ON_ERROR_IGNORE; @@ -423,7 +429,7 @@ void FfsXmlParser::readXmlGlobalSettings(xmlAccess::XmlGlobalSettings& outputCfg //check for unresolved conflicts readXmlElementLogging("CheckForUnresolvedConflicts", optionalDialogs, outputCfg.optDialogs.warningUnresolvedConflicts); - readXmlElementLogging("CheckSyncDatabase", optionalDialogs, outputCfg.optDialogs.warningSyncDatabase); + readXmlElementLogging("NotifyDatabaseError", optionalDialogs, outputCfg.optDialogs.warningSyncDatabase); readXmlElementLogging("PopupOnConfigChange", optionalDialogs, outputCfg.optDialogs.popupOnConfigChange); @@ -452,7 +458,7 @@ void FfsXmlParser::readXmlGlobalSettings(xmlAccess::XmlGlobalSettings& outputCfg readXmlAttributeLogging("ShowFileIcons", TiXmlHandleConst(mainWindow).FirstChild("LeftColumns").ToElement(), outputCfg.gui.showFileIconsLeft); const TiXmlElement* leftColumn = TiXmlHandleConst(mainWindow).FirstChild("LeftColumns").FirstChild("Column").ToElement(); - unsigned int colPos = 0; + size_t colPos = 0; while (leftColumn) { ColumnAttrib newAttrib; @@ -689,8 +695,11 @@ bool writeXmlMainConfig(const MainConfiguration& mainCfg, TiXmlDocument& doc) //max. allowed file time deviation addXmlElement("FileTimeTolerance", mainCfgLocal.hidden.fileTimeTolerance, cmpSettings); + //include symbolic links at all? + addXmlElement("IncludeSymlinks", mainCfgLocal.processSymlinks, cmpSettings); + //traverse into symbolic links (to folders) - addXmlElement("TraverseDirectorySymlinks", mainCfgLocal.hidden.traverseDirectorySymlinks, cmpSettings); + addXmlElement("TraverseDirectorySymlinks", mainCfgLocal.traverseDirectorySymlinks, cmpSettings); //########################################################### TiXmlElement* syncSettings = new TiXmlElement("Synchronization"); @@ -711,7 +720,7 @@ bool writeXmlMainConfig(const MainConfiguration& mainCfg, TiXmlDocument& doc) //########################################################### //copy symbolic links to files - addXmlElement("CopyFileSymlinks", mainCfgLocal.hidden.copyFileSymlinks, syncSettings); + addXmlElement("CopyFileSymlinks", mainCfgLocal.copyFileSymlinks, syncSettings); //verify file copying addXmlElement("VerifyCopiedFiles", mainCfgLocal.hidden.verifyFileCopy, syncSettings); @@ -724,9 +733,8 @@ bool writeXmlMainConfig(const MainConfiguration& mainCfg, TiXmlDocument& doc) TiXmlElement* filter = new TiXmlElement("Filter"); miscSettings->LinkEndChild(filter); - addXmlElement("Active", mainCfgLocal.filterIsActive, filter); - addXmlElement("Include", mainCfgLocal.includeFilter, filter); - addXmlElement("Exclude", mainCfgLocal.excludeFilter, filter); + addXmlElement("Include", mainCfgLocal.globalFilter.includeFilter, filter); + addXmlElement("Exclude", mainCfgLocal.globalFilter.excludeFilter, filter); //other addXmlElement("DeletionPolicy", mainCfgLocal.handleDeletion, miscSettings); @@ -827,7 +835,7 @@ bool writeXmlGlobalSettings(const xmlAccess::XmlGlobalSettings& inputCfg, TiXmlD //check for unresolved conflicts addXmlElement("CheckForUnresolvedConflicts", inputCfg.optDialogs.warningUnresolvedConflicts, optionalDialogs); - addXmlElement("CheckSyncDatabase", inputCfg.optDialogs.warningSyncDatabase, optionalDialogs); + addXmlElement("NotifyDatabaseError", inputCfg.optDialogs.warningSyncDatabase, optionalDialogs); addXmlElement("PopupOnConfigChange", inputCfg.optDialogs.popupOnConfigChange, optionalDialogs); @@ -868,7 +876,7 @@ bool writeXmlGlobalSettings(const xmlAccess::XmlGlobalSettings& inputCfg, TiXmlD ColumnAttributes columnAtrribLeftCopy = inputCfg.gui.columnAttribLeft; //can't change const vector sort(columnAtrribLeftCopy.begin(), columnAtrribLeftCopy.end(), xmlAccess::sortByPositionOnly); - for (unsigned int i = 0; i < columnAtrribLeftCopy.size(); ++i) + for (size_t i = 0; i < columnAtrribLeftCopy.size(); ++i) { TiXmlElement* subElement = new TiXmlElement("Column"); leftColumn->LinkEndChild(subElement); @@ -887,7 +895,7 @@ bool writeXmlGlobalSettings(const xmlAccess::XmlGlobalSettings& inputCfg, TiXmlD ColumnAttributes columnAtrribRightCopy = inputCfg.gui.columnAttribRight; sort(columnAtrribRightCopy.begin(), columnAtrribRightCopy.end(), xmlAccess::sortByPositionOnly); - for (unsigned int i = 0; i < columnAtrribRightCopy.size(); ++i) + for (size_t i = 0; i < columnAtrribRightCopy.size(); ++i) { TiXmlElement* subElement = new TiXmlElement("Column"); rightColumn->LinkEndChild(subElement); @@ -964,7 +972,7 @@ void xmlAccess::OptionalDialogs::resetDialogs() } -xmlAccess::XmlGuiConfig convertBatchToGui(const xmlAccess::XmlBatchConfig& batchCfg) +xmlAccess::XmlGuiConfig xmlAccess::convertBatchToGui(const xmlAccess::XmlBatchConfig& batchCfg) { xmlAccess::XmlGuiConfig output; output.mainCfg = batchCfg.mainCfg; diff --git a/library/processXml.h b/library/processXml.h index 13282de9..b46f0163 100644 --- a/library/processXml.h +++ b/library/processXml.h @@ -8,6 +8,8 @@ #define PROCESSXML_H_INCLUDED #include "../structures.h" +#include "../shared/xmlError.h" + namespace xmlAccess { @@ -20,7 +22,7 @@ enum OnError enum ColumnTypes { - DIRECTORY, + DIRECTORY, //this needs to begin with 0 and be continuous (some code relies on it) FULL_PATH, REL_PATH, FILENAME, @@ -28,13 +30,13 @@ enum ColumnTypes DATE, EXTENSION }; -const unsigned int COLUMN_TYPE_COUNT = 7; +const size_t COLUMN_TYPE_COUNT = 7; struct ColumnAttrib { ColumnTypes type; bool visible; - unsigned int position; + size_t position; int width; }; typedef std::vector<ColumnAttrib> ColumnAttributes; @@ -80,8 +82,8 @@ struct XmlBatchConfig FreeFileSync::MainConfiguration mainCfg; bool silent; + wxString logFileDirectory; OnError handleError; //reaction on error situation during synchronization - wxString logFileDirectory; // }; int retrieveSystemLanguage(); @@ -154,11 +156,13 @@ struct XmlGlobalSettings #ifdef FFS_WIN externelApplications.push_back(std::make_pair(wxT("Open with Explorer"), //mark for extraction: _("Open with Explorer") wxT("explorer /select, \"%name\""))); - externelApplications.push_back(std::make_pair(wxT("Open directly"), //mark for extraction: _("Open directly") + externelApplications.push_back(std::make_pair(wxT("Open with default application"), //mark for extraction: _("Open with default application") wxT("cmd /c start \"\" \"%name\""))); #elif defined FFS_LINUX - externelApplications.push_back(std::make_pair(wxT("Open with Konqueror"), //mark for extraction: _("Open with Konqueror") - wxT("konqueror \"%dir\""))); + externelApplications.push_back(std::make_pair(wxT("Browse directory"), //mark for extraction: _("Browse directory") + wxT("xdg-open \"%dir\""))); + externelApplications.push_back(std::make_pair(wxT("Open with default application"), //mark for extraction: _("Open with default application") + wxT("xdg-open \"%name\""))); #endif } @@ -230,6 +234,7 @@ void readBatchConfig(const wxString& filename, XmlBatchConfig& config); //thr void readGlobalSettings( XmlGlobalSettings& config); //throw (xmlAccess::XmlError); void readGuiOrBatchConfig(const wxString& filename, XmlGuiConfig& config); //throw (xmlAccess::XmlError); +XmlGuiConfig convertBatchToGui(const XmlBatchConfig& batchCfg); void writeGuiConfig( const XmlGuiConfig& outputCfg, const wxString& filename); //throw (xmlAccess::XmlError); void writeBatchConfig( const XmlBatchConfig& outputCfg, const wxString& filename); //throw (xmlAccess::XmlError); diff --git a/library/resources.cpp b/library/resources.cpp index ae39d9e7..2104efc3 100644 --- a/library/resources.cpp +++ b/library/resources.cpp @@ -52,7 +52,7 @@ void loadAnimFromZip(wxZipInputStream& zipInput, wxAnimation* animation) //Workaround for wxWidgets: //construct seekable input stream (zip-input stream is non-seekable) for wxAnimation::Load() //luckily this method call is very fast: below measurement precision! - std::vector<unsigned char> data; + std::vector<char> data; data.reserve(10000); int newValue = 0; diff --git a/library/softFilter.h b/library/softFilter.h index e4735e38..275aa9bd 100644 --- a/library/softFilter.h +++ b/library/softFilter.h @@ -11,7 +11,7 @@ #include <wx/timer.h> /* Semantics of SoftFilter: -1. It potentially can match only one side => it MUST NOT be applied while traversing a single folder to avoid mismatches +1. It potentially may match only one side => it MUST NOT be applied while traversing a single folder to avoid mismatches 2. => it is applied after traversing and just marks rows, (NO deletions after comparison are allowed) 3. => not relevant for <Automatic>-mode! ;) @@ -28,19 +28,23 @@ public: timeWindow_(timeWindow), currentTime(wxGetUTCTime()) {} +// typedef boost::shared_ptr<const SoftFilter> FilterRef; //always bound by design! + bool passFilter(const FileMapping& fileMap) const; bool passFilter(const DirMapping& dirMap) const; private: - const size_t timeWindow_; //point in time from "now" (in seconds) for oldest modification date to be allowed - const long currentTime; //number of seconds since GMT 00:00:00 Jan 1st 1970. + const size_t timeWindow_; //point in time from "now" (in seconds) for oldest modification date to be allowed + const long currentTime; //number of seconds since GMT 00:00:00 Jan 1st 1970. }; - - - - +//SoftFilter::FilterRef combineFilters(const SoftFilter& first, +// const SoftFilter& second); +// +// +// +// diff --git a/library/statistics.cpp b/library/statistics.cpp index 6e64be1c..fc140add 100644 --- a/library/statistics.cpp +++ b/library/statistics.cpp @@ -54,14 +54,14 @@ void RetrieveStatistics::writeEntry(const double value, const int objects) //######################################################################################## inline -bool isNull(const double number) +bool isNull(double number) { - return globalFunctions::abs(number) <= std::numeric_limits<double>::epsilon(); + return globalFunctions::abs(number) < std::numeric_limits<double>::epsilon(); } inline -wxString Statistics::formatRemainingTime(const double timeInMs) const +wxString Statistics::formatRemainingTime(double timeInMs) const { bool unitSec = true; double remainingTime = timeInMs / 1000; @@ -118,7 +118,7 @@ Statistics::Statistics(const int totalObjectCount, windowSizeRemTime(windowSizeRemainingTime), windowSizeBPS(windowSizeBytesPerSecond), windowMax(std::max(windowSizeRemainingTime, windowSizeBytesPerSecond)), - remainingTimeLast(256*256*256*100), //something "big" + remainingTimeLast(std::numeric_limits<int>::max()), //something "big" timer(new wxStopWatch) {} Statistics::~Statistics() diff --git a/library/statistics.h b/library/statistics.h index f7bec519..ba9d8afb 100644 --- a/library/statistics.h +++ b/library/statistics.h @@ -11,9 +11,9 @@ #include <list> #include <memory> #include <wx/defs.h> +#include <wx/string.h> class wxStopWatch; -class wxString; class RetrieveStatistics |