From fd0853d2623dd278b08288331ed42e3be59252fb Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:00:17 +0200 Subject: 2.2 --- RealtimeSync/xmlFreeFileSync.cpp | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 RealtimeSync/xmlFreeFileSync.cpp (limited to 'RealtimeSync/xmlFreeFileSync.cpp') diff --git a/RealtimeSync/xmlFreeFileSync.cpp b/RealtimeSync/xmlFreeFileSync.cpp new file mode 100644 index 00000000..36f0e2f8 --- /dev/null +++ b/RealtimeSync/xmlFreeFileSync.cpp @@ -0,0 +1,68 @@ +#include "xmlFreeFileSync.h" +#include "../shared/standardPaths.h" +#include "../shared/globalFunctions.h" +#include "../shared/zstring.h" +#include "functions.h" +#include "../shared/xmlBase.h" + +//include FreeFileSync xml headers +#include "../library/processXml.h" + + +#ifdef FFS_WIN +class CmpNoCase +{ +public: + bool operator()(const wxString& a, const wxString& b) + { + return FreeFileSync::compareStringsWin32(a.c_str(), b.c_str(), a.length(), b.length()) < 0; + } +}; +#endif + + +void RealtimeSync::readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConfig& config) //throw (xmlAccess::XmlError); +{ + if (xmlAccess::getXmlType(filename) != xmlAccess::XML_BATCH_CONFIG) + { + xmlAccess::readRealConfig(filename, config); + return; + } + + //convert batch config to RealtimeSync config + xmlAccess::XmlBatchConfig batchCfg; + try + { + xmlAccess::readBatchConfig(filename, batchCfg); //throw (xmlAccess::XmlError); + } + catch (const xmlAccess::XmlError& e) + { + if (e.getSeverity() != xmlAccess::XmlError::WARNING) //ignore parsing errors + throw; + } + +#ifdef FFS_WIN + std::set uniqueFolders; +#elif defined FFS_LINUX + std::set uniqueFolders; +#endif + + for (std::vector::const_iterator i = batchCfg.directoryPairs.begin(); i != batchCfg.directoryPairs.end(); ++i) + { + uniqueFolders.insert(i->leftDirectory.c_str()); + uniqueFolders.insert(i->rightDirectory.c_str()); + } + + config.directories.insert(config.directories.end(), uniqueFolders.begin(), uniqueFolders.end()); + + config.commandline = FreeFileSync::getInstallationDir() + globalFunctions::FILE_NAME_SEPARATOR + wxT("FreeFileSync.exe ") + + wxT("\"") + filename + wxT("\""); +} + + +int RealtimeSync::getProgramLanguage() +{ + xmlAccess::XmlGlobalSettings settings; + xmlAccess::readGlobalSettings(settings); + return settings.programLanguage; +} -- cgit