summaryrefslogtreecommitdiff
path: root/RealtimeSync/xmlFreeFileSync.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:00:17 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:00:17 +0200
commitfd0853d2623dd278b08288331ed42e3be59252fb (patch)
treea7645daeaef8bdbed064faf4eb88e72cee58726c /RealtimeSync/xmlFreeFileSync.cpp
parent2.1 (diff)
downloadFreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.tar.gz
FreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.tar.bz2
FreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.zip
2.2
Diffstat (limited to 'RealtimeSync/xmlFreeFileSync.cpp')
-rw-r--r--RealtimeSync/xmlFreeFileSync.cpp68
1 files changed, 68 insertions, 0 deletions
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<wxString, CmpNoCase> uniqueFolders;
+#elif defined FFS_LINUX
+ std::set<wxString> uniqueFolders;
+#endif
+
+ for (std::vector<FreeFileSync::FolderPair>::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;
+}
bgstack15