]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on getAbsolutePath and getStatus
authorArvin Schnell <aschnell@suse.de>
Mon, 17 Jan 2011 15:10:39 +0000 (16:10 +0100)
committerArvin Schnell <aschnell@suse.de>
Mon, 17 Jan 2011 15:10:39 +0000 (16:10 +0100)
snapper/Snapper.cc
snapper/Snapper.h
snapper/SnapperInterface.h

index 6dbdde46ecefbac89f4d275290687630ee249f48..be5d357e8781e2e2779cde8efff04cfc8b4aeb38 100644 (file)
@@ -78,6 +78,25 @@ namespace snapper
     }
 
 
+    string
+    getAbsolutePath(const string& name, Location loc)
+    {
+       switch (loc)
+       {
+           case LOC_PRE:
+               return snapshotDir(snapshot1) + name;
+
+           case LOC_POST:
+               return snapshotDir(snapshot2) + name;
+
+           case LOC_SYSTEM:
+               return name;
+       }
+
+       return "error";
+    }
+
+
     void
     readSnapshots()
     {
@@ -459,22 +478,59 @@ namespace snapper
 
 
     unsigned int
-    getStatus(const string& name, Cmp cmp)
+    File::getPreToPostStatus()
     {
-       vector<File>::const_iterator it = filelist.find(name);
-       if (it != filelist.end())
+       return pre_to_post_status;
+    }
+
+
+    unsigned int
+    File::getPreToSystemStatus()
+    {
+       if (pre_to_system_status == (unsigned int)(-1))
+           pre_to_system_status = cmpFiles(getAbsolutePath(name, LOC_PRE),
+                                           getAbsolutePath(name, LOC_SYSTEM));
+       return pre_to_system_status;
+    }
+
+
+    unsigned int
+    File::getPostToSystemStatus()
+    {
+       if (post_to_system_status == (unsigned int)(-1))
+           post_to_system_status = cmpFiles(getAbsolutePath(name, LOC_POST),
+                                            getAbsolutePath(name, LOC_SYSTEM));
+       return post_to_system_status;
+    }
+
+
+    unsigned int
+    File::getStatus(Cmp cmp)
+    {
+       switch (cmp)
        {
-           switch (cmp)
-           {
-               case CMP_PRE_TO_POST:
-                   return it->pre_to_post_status;
-               case CMP_PRE_TO_SYSTEM:
-                   return it->pre_to_system_status;
-               case CMP_POST_TO_SYSTEM:
-                   return it->post_to_system_status;
-           }
+           case CMP_PRE_TO_POST:
+               return getPreToPostStatus();
+
+           case CMP_PRE_TO_SYSTEM:
+               return getPreToSystemStatus();
+
+           case CMP_POST_TO_SYSTEM:
+               return getPostToSystemStatus();
        }
 
        return -1;
     }
+
+
+    unsigned int
+    getStatus(const string& name, Cmp cmp)
+    {
+       vector<File>::iterator it = filelist.find(name);
+       if (it != filelist.end())
+           return it->getStatus(cmp);
+
+       return -1;
+    }
+
 }
index 6b947d902eb51af59be4343ebbed5319cb2f301e..9425d9db0661f4aef4a4af69b272eedf1f5300ea 100644 (file)
@@ -58,6 +58,12 @@ namespace snapper
              post_to_system_status(-1), rollback(false)
        {}
 
+       unsigned int getPreToPostStatus();
+       unsigned int getPreToSystemStatus();
+       unsigned int getPostToSystemStatus();
+
+       unsigned int getStatus(Cmp cmp);
+
        string name;
 
        unsigned int pre_to_post_status; // -1 if invalid
index 3b996f11498c8c91c5f82b53b6d2ac14d1ad93bd..2afe91de4c5ba5687acd9e291905cb4a2005ad72 100644 (file)
@@ -102,12 +102,12 @@ namespace snapper
     list<string> getFiles();
 
     // return bitfield of StatusFlags
-    unsigned int getStatus(const string& file, Cmp cmp);
+    unsigned int getStatus(const string& name, Cmp cmp);
 
-    string getAbsolutePath(const string& file, Location loc);
+    string getAbsolutePath(const string& name, Location loc);
 
-    void setRollback(const string& file, bool rollback);
-    bool getRollback(const string& file);
+    void setRollback(const string& name, bool rollback);
+    bool getRollback(const string& name);
 
     // check rollback? (e.g. to be deleted dirs are empty, required type changes)
     bool checkRollback();