From: Arvin Schnell Date: Mon, 27 Aug 2012 16:46:30 +0000 (+0200) Subject: - work on dbus interface X-Git-Tag: v0.1.3~141 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=02656224d8449b46561c78366eb553953bc4dff8;p=thirdparty%2Fsnapper.git - work on dbus interface --- diff --git a/snapper/AsciiFile.cc b/snapper/AsciiFile.cc index cc829a10..2e2127e0 100644 --- a/snapper/AsciiFile.cc +++ b/snapper/AsciiFile.cc @@ -35,6 +35,17 @@ namespace snapper using namespace std; + AsciiFileReader::AsciiFileReader(int fd) + : file(fdopen(fd, "r")), buffer(NULL), len(0) + { + if (file == NULL) + { + y2war("file is NULL"); + throw FileNotFoundException(); + } + } + + AsciiFileReader::AsciiFileReader(FILE* file) : file(file), buffer(NULL), len(0) { diff --git a/snapper/AsciiFile.h b/snapper/AsciiFile.h index b3f5cc75..0143cdca 100644 --- a/snapper/AsciiFile.h +++ b/snapper/AsciiFile.h @@ -38,6 +38,7 @@ namespace snapper { public: + AsciiFileReader(int fd); AsciiFileReader(FILE* file); AsciiFileReader(const string& filename); ~AsciiFileReader(); diff --git a/snapper/XmlFile.cc b/snapper/XmlFile.cc index 1ae64952..34f294d2 100644 --- a/snapper/XmlFile.cc +++ b/snapper/XmlFile.cc @@ -37,6 +37,14 @@ namespace snapper } + XmlFile::XmlFile(int fd, const string& url) + : doc(xmlReadFd(fd, url.c_str(), NULL, XML_PARSE_NOBLANKS | XML_PARSE_NONET)) + { + if (!doc) + throw IOErrorException(); + } + + XmlFile::XmlFile(const string& filename) : doc(xmlReadFile(filename.c_str(), NULL, XML_PARSE_NOBLANKS | XML_PARSE_NONET)) { @@ -51,6 +59,14 @@ namespace snapper } + void + XmlFile::save(int fd) + { + if (xmlDocDump(fdopen(fd, "w"), doc) == -1) + throw IOErrorException(); + } + + void XmlFile::save(const string& filename) { diff --git a/snapper/XmlFile.h b/snapper/XmlFile.h index 73ca2a91..58130c94 100644 --- a/snapper/XmlFile.h +++ b/snapper/XmlFile.h @@ -44,10 +44,12 @@ namespace snapper public: XmlFile(); + XmlFile(int fd, const string& url); XmlFile(const string& filename); ~XmlFile(); + void save(int fd); void save(const string& filename); void setRootElement(xmlNode* node)