From 4ecfd41e36533d858c98d051ef70cab80e69e972 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:00:50 +0200 Subject: 2.3 --- RealtimeSync/xmlFreeFileSync.cpp | 68 +++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 22 deletions(-) (limited to 'RealtimeSync/xmlFreeFileSync.cpp') diff --git a/RealtimeSync/xmlFreeFileSync.cpp b/RealtimeSync/xmlFreeFileSync.cpp index 36f0e2f8..b3c11d50 100644 --- a/RealtimeSync/xmlFreeFileSync.cpp +++ b/RealtimeSync/xmlFreeFileSync.cpp @@ -10,17 +10,47 @@ #ifdef FFS_WIN -class CmpNoCase +struct CmpNoCase { -public: - bool operator()(const wxString& a, const wxString& b) + bool operator()(const wxString& a, const wxString& b) const { - return FreeFileSync::compareStringsWin32(a.c_str(), b.c_str(), a.length(), b.length()) < 0; + return a.CmpNoCase(b) < 0; } }; #endif +xmlAccess::XmlRealConfig convertBatchToReal(const xmlAccess::XmlBatchConfig& batchCfg, const wxString& filename) +{ + xmlAccess::XmlRealConfig output; + +#ifdef FFS_WIN + std::set uniqueFolders; +#elif defined FFS_LINUX + std::set uniqueFolders; +#endif + + //add main folders + uniqueFolders.insert(batchCfg.mainCfg.mainFolderPair.leftDirectory.c_str()); + uniqueFolders.insert(batchCfg.mainCfg.mainFolderPair.rightDirectory.c_str()); + + //additional folders + for (std::vector::const_iterator i = batchCfg.mainCfg.additionalPairs.begin(); + i != batchCfg.mainCfg.additionalPairs.end(); ++i) + { + uniqueFolders.insert(i->leftDirectory.c_str()); + uniqueFolders.insert(i->rightDirectory.c_str()); + } + + output.directories.insert(output.directories.end(), uniqueFolders.begin(), uniqueFolders.end()); + + output.commandline = FreeFileSync::getInstallationDir() + globalFunctions::FILE_NAME_SEPARATOR + wxT("FreeFileSync.exe ") + + wxT("\"") + filename + wxT("\""); + + return output; +} + + void RealtimeSync::readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConfig& config) //throw (xmlAccess::XmlError); { if (xmlAccess::getXmlType(filename) != xmlAccess::XML_BATCH_CONFIG) @@ -37,32 +67,26 @@ void RealtimeSync::readRealOrBatchConfig(const wxString& filename, xmlAccess::Xm } catch (const xmlAccess::XmlError& e) { - if (e.getSeverity() != xmlAccess::XmlError::WARNING) //ignore parsing errors + if (e.getSeverity() != xmlAccess::XmlError::WARNING) 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 = convertBatchToReal(batchCfg, filename); //do work despite parsing errors, then re-throw + throw; // } - - config.directories.insert(config.directories.end(), uniqueFolders.begin(), uniqueFolders.end()); - - config.commandline = FreeFileSync::getInstallationDir() + globalFunctions::FILE_NAME_SEPARATOR + wxT("FreeFileSync.exe ") + - wxT("\"") + filename + wxT("\""); + config = convertBatchToReal(batchCfg, filename); } int RealtimeSync::getProgramLanguage() { xmlAccess::XmlGlobalSettings settings; - xmlAccess::readGlobalSettings(settings); + + try + { + xmlAccess::readGlobalSettings(settings); + } + catch (const xmlAccess::XmlError&) + {} //user default language if error occured + return settings.programLanguage; } -- cgit