// ************************************************************************** // * 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) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "xml_io.h" #include "file_handling.h" #include "file_io.h" #include "serialize.h" using namespace zen; XmlDoc zen::loadXmlDocument(const Zstring& filename) //throw FileError { //can't simply use zen::loadBinStream() due to the short-circuit xml-validation below! std::string stream; FileInput inputFile(filename); //throw FileError { //quick test whether input is an XML: avoid loading large binary files up front! const std::string xmlBegin = "(e.row + 1)), L"%z", numberTo(e.col + 1))); } } void zen::saveXmlDocument(const XmlDoc& doc, const Zstring& filename) //throw FileError { std::string stream = serialize(doc); //noexcept //only update xml file if there are real changes try { if (getFilesize(filename) == stream.size()) //throw FileError if (loadBinStream(filename) == stream) //throw FileError return; } catch (FileError&) {} FileOutput outputFile(filename, FileOutput::ACC_OVERWRITE); //throw FileError outputFile.write(stream.c_str(), stream.length()); // } void zen::checkForMappingErrors(const XmlIn& xmlInput, const Zstring& filename) //throw FileError { if (xmlInput.errorsOccured()) { std::wstring msg = _("Cannot read the following XML elements:") + L"\n"; for (const std::wstring& elem : xmlInput.getErrorsAs()) msg += L"\n" + elem; throw FileError(replaceCpy(_("Configuration file %x loaded partially only."), L"%x", fmtFileName(filename)) + L"\n\n" + msg); } }