]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- added stringToStatus
authorArvin Schnell <aschnell@suse.de>
Thu, 13 Jan 2011 15:54:15 +0000 (16:54 +0100)
committerArvin Schnell <aschnell@suse.de>
Thu, 13 Jan 2011 15:54:15 +0000 (16:54 +0100)
snapper/Files.cc
snapper/Files.h

index d5ff5c74147bf5306095b19e2b2561b57b7a9fb8..efc2069252fd7fa953b29ce7bc13e9594259d1f8 100644 (file)
@@ -378,8 +378,10 @@ namespace snapper
        y2mil("path1:" << path1 << " path2:" << path2);
 
        CmpData cmp_data;
+
        cmp_data.base_path1 = path1;
        cmp_data.base_path2 = path2;
+
        cmp_data.cb = cb;
 
        struct stat stat1;
@@ -421,4 +423,44 @@ namespace snapper
        return ret;
     }
 
+
+    unsigned int
+    stringToStatus(const string& str)
+    {
+       unsigned int ret = 0;
+
+       assert(str.length() == 4);
+
+       if (str.length() >= 1)
+       {
+           switch (str[0])
+           {
+               case '+': ret |= CREATED; break;
+               case '-': ret |= DELETED; break;
+               case 't': ret |= TYPE; break;
+               case 'c': ret |= CONTENT; break;
+           }
+       }
+
+       if (str.length() >= 2)
+       {
+           if (str[1] == 'p')
+               ret |= PERMISSIONS;
+       }
+
+       if (str.length() >= 3)
+       {
+           if (str[2] == 'u')
+               ret |= USER;
+       }
+
+       if (str.length() >= 4)
+       {
+           if (str[3] == 'g')
+               ret |= GROUP;
+       }
+
+       return ret;
+    }
+
 }
index 1672ad221c49a0eb3e6e5450137b5f5e120fa4d2..b2b8de56f635990797a59e569ce1a75e68828d88 100644 (file)
@@ -42,6 +42,9 @@ namespace snapper
     string
     statusToString(unsigned int status);
 
+    unsigned int
+    stringToStatus(const string& str);
+
 }