stop clonepath at base directory. fixes #467

This commit is contained in:
Antonio SJ Musumeci 2018-03-07 18:24:47 -05:00
parent 62ae871d51
commit f48c16d162
14 changed files with 238 additions and 267 deletions

View file

@ -26,6 +26,7 @@
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "fs_xattr.hpp"
#include "ugid.hpp"
using std::string;
@ -59,6 +60,9 @@ namespace fs
string frompath;
string dirname;
if((relative == NULL) || (relative[0] == '\0'))
return 0;
dirname = relative;
fs::path::dirname(dirname);
if(!dirname.empty())
@ -114,4 +118,29 @@ namespace fs
{
return fs::clonepath(from,to,relative.c_str());
}
int
clonepath_as_root(const string &from,
const string &to,
const char *relative)
{
if((relative == NULL) || (relative[0] == '\0'))
return 0;
if(from == to)
return 0;
{
const ugid::SetRootGuard ugidGuard;
return fs::clonepath(from,to,relative);
}
}
int
clonepath_as_root(const std::string &from,
const std::string &to,
const std::string &relative)
{
return fs::clonepath_as_root(from,to,relative.c_str());
}
}