Commit aa72147d authored by David Cameron's avatar David Cameron

enforce each entry in list starts with /

parent d2af8387
Pipeline #5994 passed with stage
in 105 minutes and 14 seconds
......@@ -476,9 +476,9 @@ bool DirDeleteExcl(const std::string& path, const std::list<std::string>& files,
// Check for any files in this dir
std::list<std::string> newfiles;
for (std::list<std::string>::const_iterator f = files.begin(); f != files.end(); ++f) {
std::string fullpath(path + '/' + *f);
std::string fullpath(path + *f);
if (fullpath.substr(0, d->size()) == *d && fullpath.size() > d->size() && fullpath[d->size()] == '/') {
newfiles.push_back(f->substr(f->find('/')+1));
newfiles.push_back(f->substr(f->find('/', 1)));
}
}
if (!newfiles.empty()) {
......@@ -489,7 +489,7 @@ bool DirDeleteExcl(const std::string& path, const std::list<std::string>& files,
bool del = excl;
for (std::list<std::string>::const_iterator f = files.begin(); f != files.end(); ++f) {
std::string fullpath(path + '/' + *f);
std::string fullpath(path + *f);
if (fullpath == *d) {
del = !del;
break;
......
......@@ -99,16 +99,18 @@ namespace Arc {
Specified uid and gid are used for accessing filesystem. */
bool DirDelete(const std::string& path, bool recursive, uid_t uid, gid_t gid);
/// Delete a directory, including or excluding certain files
/// Delete contents of a directory, including or excluding certain files
/** If excl is true, all files except those specified in files will be
deleted. If excl is false, only the files in files will be deleted.
files is a list of paths relative to path.*/
files is a list of paths relative to path. Each entry must begin with '/'.
Note that path itself is not deleted. */
bool DirDeleteExcl(const std::string& path, const std::list<std::string>& files, bool excl);
/// Delete a directory, including or excluding certain files, using the specified uid and gid
/// Delete contents of a directory, including or excluding certain files, using the specified uid and gid
/** If excl is true, all files except those specified in files will be
deleted. If excl is false, only the files in files will be deleted.
files is a list of paths relative to path.*/
files is a list of paths relative to path. Each entry must begin with '/'.
Note that path itself is not deleted. */
bool DirDeleteExcl(const std::string& path, const std::list<std::string>& files, bool excl, uid_t uid, gid_t gid);
/// List all entries in a directory.
......
......@@ -164,8 +164,8 @@ void FileUtilsTest::TestMakeAndDeleteDir() {
CPPUNIT_ASSERT(stat(std::string(testroot+sep+link1).c_str(), &st) == 0);
files.clear();
files.push_back(file1);
files.push_back(dir2);
files.push_back("/" + file1);
files.push_back("/" + dir2);
// Delete everything except file1 and dir2
CPPUNIT_ASSERT(Arc::DirDeleteExcl(testroot, files, true));
CPPUNIT_ASSERT(stat(std::string(testroot+sep+dir3).c_str(), &st) != 0);
......
......@@ -55,7 +55,7 @@ bool compare_job_description(GMJobRef const& first, GMJobRef const& second) {
std::string filedata_pfn(FileData const& fd) {
return fd.pfn;
}
void DTRGenerator::main_thread(void* arg) {
((DTRGenerator*)arg)->thread();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment