From: Arvin Schnell Date: Wed, 3 Aug 2011 12:55:07 +0000 (+0200) Subject: - avoid double slash in paths X-Git-Tag: v0.1.3~320 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=6d366cfc3e38b76753ce1fa9905ee8b7bcdd26ce;p=thirdparty%2Fsnapper.git - avoid double slash in paths --- diff --git a/snapper/File.cc b/snapper/File.cc index 1cbf0be8..a3451e46 100644 --- a/snapper/File.cc +++ b/snapper/File.cc @@ -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())); } diff --git a/snapper/Filesystem.cc b/snapper/Filesystem.cc index 6f96ce90..a65e0c27 100644 --- a/snapper/Filesystem.cc +++ b/snapper/Filesystem.cc @@ -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); }