]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on dbus interface
authorArvin Schnell <aschnell@suse.de>
Mon, 27 Aug 2012 16:46:30 +0000 (18:46 +0200)
committerArvin Schnell <aschnell@suse.de>
Mon, 27 Aug 2012 16:46:30 +0000 (18:46 +0200)
snapper/AsciiFile.cc
snapper/AsciiFile.h
snapper/XmlFile.cc
snapper/XmlFile.h

index cc829a10d332b899ef7ca09031204eb55b44fb3e..2e2127e0c2f3a439c2788aeb3e01d20f415cfef4 100644 (file)
@@ -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)
     {
index b3f5cc753639bdb96b39e148914dd39f430bd6e4..0143cdca3217b459965e49053f2fbd31c78ab9b1 100644 (file)
@@ -38,6 +38,7 @@ namespace snapper
     {
     public:
 
+       AsciiFileReader(int fd);
        AsciiFileReader(FILE* file);
        AsciiFileReader(const string& filename);
        ~AsciiFileReader();
index 1ae64952d6bfad7a51fdc32738e4bf5b486079ce..34f294d20eee55127a214faaaeee22817ccbfc26 100644 (file)
@@ -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)
     {
index 73ca2a91c3b614222be0db6bb90c52a4003b8a03..58130c940be2681111c601020a08e88151994dd7 100644 (file)
@@ -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)