mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 23:43:26 +01:00
Read config into memory and pass its content to tinyxml2 (#253)
tinyxml2 does not support to read from a named pipe, since it uses seek to figure out the file size. In the case of a pipe this is not possible. Reading the file content into memory and passing the content to tinyxml2 allows to mitigate this problem.
This commit is contained in:
parent
f75854cd31
commit
59378ae7fe
@ -23,6 +23,8 @@
|
|||||||
#include <algorithm> // for remove_if
|
#include <algorithm> // for remove_if
|
||||||
#include <cstring> // for NULL
|
#include <cstring> // for NULL
|
||||||
#include <memory> // for shared_ptr
|
#include <memory> // for shared_ptr
|
||||||
|
#include <fstream> // for ifstream
|
||||||
|
#include <sstream> // for ostringstream
|
||||||
|
|
||||||
#include <tinyxml2.h> // for XMLElement, XMLNode, XMLDocument (ptr only)
|
#include <tinyxml2.h> // for XMLElement, XMLNode, XMLDocument (ptr only)
|
||||||
|
|
||||||
@ -167,7 +169,12 @@ XmlReader::~XmlReader() {}
|
|||||||
bool XmlReader::load(const char *fileName) {
|
bool XmlReader::load(const char *fileName) {
|
||||||
pd->doc.reset(new tinyxml2::XMLDocument());
|
pd->doc.reset(new tinyxml2::XMLDocument());
|
||||||
|
|
||||||
auto err = pd->doc->LoadFile(fileName);
|
std::ifstream in(fileName);
|
||||||
|
if (!in) return false;
|
||||||
|
|
||||||
|
std::ostringstream fileContent;
|
||||||
|
fileContent << in.rdbuf();
|
||||||
|
auto err = pd->doc->Parse(fileContent.str().c_str());
|
||||||
return err == tinyxml2::XML_SUCCESS;
|
return err == tinyxml2::XML_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user