]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- avoid double slash in paths
authorArvin Schnell <aschnell@suse.de>
Wed, 3 Aug 2011 12:55:07 +0000 (14:55 +0200)
committerArvin Schnell <aschnell@suse.de>
Wed, 3 Aug 2011 12:55:07 +0000 (14:55 +0200)
snapper/File.cc
snapper/Filesystem.cc

index 1cbf0be8fd1e10f08cdd37ac281607e55f6ab16e..a3451e46e7eacdca990277200ef3ad5cdee9333f 100644 (file)
@@ -315,20 +315,30 @@ namespace snapper
     Files::iterator
     Files::findAbsolutePath(const string& filename)
     {
-       if (!boost::starts_with(filename, getSnapper()->subvolumeDir()))
+       string subvolume = getSnapper()->subvolumeDir();
+
+       if (!boost::starts_with(filename, subvolume))
            return end();
 
-       return find(string(filename, getSnapper()->subvolumeDir().size()));
+       if (subvolume == "/")
+           return find(filename);
+       else
+           return find(string(filename, subvolume.size()));
     }
 
 
     Files::const_iterator
     Files::findAbsolutePath(const string& filename) const
     {
-       if (!boost::starts_with(filename, getSnapper()->subvolumeDir()))
+       string subvolume = getSnapper()->subvolumeDir();
+
+       if (!boost::starts_with(filename, subvolume))
            return end();
 
-       return find(string(filename, getSnapper()->subvolumeDir().size()));
+       if (subvolume == "/")
+           return find(filename);
+       else
+           return find(string(filename, subvolume.size()));
     }
 
 
index 6f96ce90fe508b6ef3fcc8af581fe4faaf3484bd..a65e0c278cdd504ac7b2545617fbde86a6457478 100644 (file)
@@ -61,14 +61,15 @@ namespace snapper
     string
     Btrfs::infosDir() const
     {
-       return subvolume + "/.snapshots";
+       return (subvolume == "/" ? "" : subvolume) + "/.snapshots";
     }
 
 
     string
     Btrfs::snapshotDir(unsigned int num) const
     {
-       return subvolume + "/.snapshots/" + decString(num) + "/snapshot";
+       return (subvolume == "/" ? "" : subvolume) + "/.snapshots/" +
+           decString(num) + "/snapshot";
     }
 
 
@@ -142,7 +143,7 @@ namespace snapper
     string
     Ext4::infosDir() const
     {
-       return subvolume + "/.snapshots/.info";
+       return (subvolume == "/" ? "" : subvolume) + "/.snapshots/.info";
     }
 
 
@@ -156,7 +157,7 @@ namespace snapper
     string
     Ext4::snapshotFile(unsigned int num) const
     {
-       return subvolume + "/.snapshots/" + decString(num);
+       return (subvolume == "/" ? "" : subvolume) + "/.snapshots/" + decString(num);
     }