diff options
author | B. Stack <bgstack15@gmail.com> | 2022-10-11 11:16:39 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-10-11 11:16:39 -0400 |
commit | cab22f2dc3c5f41b5163f74cbb233e390edff6ff (patch) | |
tree | a49cfd729d9793681a57fa6f7409b0f0848e9ede /zenXml/zenxml | |
parent | Merge branch 'b11.25' into 'master' (diff) | |
download | FreeFileSync-cab22f2dc3c5f41b5163f74cbb233e390edff6ff.tar.gz FreeFileSync-cab22f2dc3c5f41b5163f74cbb233e390edff6ff.tar.bz2 FreeFileSync-cab22f2dc3c5f41b5163f74cbb233e390edff6ff.zip |
add upstream 11.26
Diffstat (limited to 'zenXml/zenxml')
-rw-r--r-- | zenXml/zenxml/dom.h | 2 | ||||
-rw-r--r-- | zenXml/zenxml/xml.h | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/zenXml/zenxml/dom.h b/zenXml/zenxml/dom.h index 427e89f2..5befdd7f 100644 --- a/zenXml/zenxml/dom.h +++ b/zenXml/zenxml/dom.h @@ -217,7 +217,7 @@ public: \code auto itPair = elem.getAttributes(); for (auto it = itPair.first; it != itPair.second; ++it) - std::cout << "name: " << it->name << " value: " << it->value << '\n'; + std::cout << std::string("name: ") + it->name + " value: " + it->value + '\n'; \endcode \return A pair of STL begin/end iterators to access all attributes sequentially as a list of name/value pairs of std::string. */ std::pair<AttrIter, AttrIter> getAttributes() const { return {attributes_.begin(), attributes_.end()}; } diff --git a/zenXml/zenxml/xml.h b/zenXml/zenxml/xml.h index 829bb5f3..c87655ba 100644 --- a/zenXml/zenxml/xml.h +++ b/zenXml/zenxml/xml.h @@ -34,16 +34,17 @@ namespace { XmlDoc loadXml(const Zstring& filePath) //throw FileError { - FileInput fileIn(filePath, nullptr /*notifyUnbufferedIO*/); //throw FileError, ErrorFileLocked - const size_t blockSize = fileIn.getBlockSize(); + FileInputPlain fileIn(filePath); //throw FileError + const size_t blockSize = fileIn.getBlockSize(); //throw FileError const std::string xmlPrefix = "<?xml version="; bool xmlPrefixChecked = false; std::string buffer; for (;;) { + warn_static("don't need zero-initialization! => resize_and_overwrite") buffer.resize(buffer.size() + blockSize); - const size_t bytesRead = fileIn.read(&*(buffer.end() - blockSize), blockSize); //throw FileError, ErrorFileLocked, (X); return "bytesToRead" bytes unless end of stream! + const size_t bytesRead = fileIn.tryRead(&*(buffer.end() - blockSize), blockSize); //throw FileError; may return short, only 0 means EOF! CONTRACT: bytesToRead > 0! buffer.resize(buffer.size() - blockSize + bytesRead); //caveat: unsigned arithmetics //quick test whether input is an XML: avoid loading large binary files up front! @@ -55,7 +56,7 @@ XmlDoc loadXml(const Zstring& filePath) //throw FileError throw FileError(replaceCpy(_("File %x does not contain a valid configuration."), L"%x", fmtPath(filePath))); } - if (bytesRead < blockSize) //end of file + if (bytesRead == 0) //end of file break; } |