#include <unistd.h>
#include <fnmatch.h>
#include <errno.h>
+#include <boost/algorithm/string.hpp>
#include "snapper/File.h"
#include "snapper/Snapper.h"
}
+ Files::iterator
+ Files::findAbsolutePath(const string& filename)
+ {
+ if (!boost::starts_with(filename, getSnapper()->subvolumeDir()))
+ return end();
+
+ return find(string(filename, getSnapper()->subvolumeDir().size()));
+ }
+
+
+ Files::const_iterator
+ Files::findAbsolutePath(const string& filename) const
+ {
+ if (!boost::starts_with(filename, getSnapper()->subvolumeDir()))
+ return end();
+
+ return find(string(filename, getSnapper()->subvolumeDir().size()));
+ }
+
+
unsigned int
File::getPreToSystemStatus()
{
iterator find(const string& name);
const_iterator find(const string& name) const;
+ iterator findAbsolutePath(const string& name);
+ const_iterator findAbsolutePath(const string& name) const;
+
private:
void initialize();
if ((opt = opts.find("file")) != opts.end())
{
- tmp = files.find(opt->second);
+ tmp = files.findAbsolutePath(opt->second);
if (tmp == files.end())
{
cerr << sformat(_("File '%s' not included in diff."), opt->second.c_str()) << endl;
if (tmp == files.end())
{
for (Files::const_iterator it = files.begin(); it != files.end(); ++it)
- fprintf(file, "%s %s\n", statusToString(it->getPreToPostStatus()).c_str(), it->getName().c_str());
+ fprintf(file, "%s %s\n", statusToString(it->getPreToPostStatus()).c_str(),
+ it->getAbsolutePath(LOC_SYSTEM).c_str());
}
else
{
name.erase(0, pos + 1);
}
- Files::iterator it = files.find(name);
+ Files::iterator it = files.findAbsolutePath(name);
if (it == files.end())
{
cerr << sformat(_("File '%s' not found in diff."), name.c_str()) << endl;