Browse Source

- added directory check

master
Andreas Romeyke 3 years ago
parent
commit
40140264d3
  1. 27
      src/lib/payload.cpp

27
src/lib/payload.cpp

@ -32,11 +32,13 @@ list<string> Payload::get_all_relative_paths() {
list<fs::path> paths;
list<string> strpaths;
fs::path directory(this->basedir + "/data");
Payload::scan_dir_recursively( directory, paths);
for (auto & path : paths) {
if (fs::is_regular_file( path )) {
fs::path relpath = fs::relative(path, this->basedir);
strpaths.push_back( relpath.string() );
if (fs::is_directory( directory )) {
Payload::scan_dir_recursively( directory, paths);
for (auto & path : paths) {
if (fs::is_regular_file( path )) {
fs::path relpath = fs::relative(path, this->basedir);
strpaths.push_back( relpath.string() );
}
}
}
return strpaths;
@ -46,23 +48,26 @@ list<string> Payload::get_all_absolute_paths() {
list<fs::path> paths;
list<string> strpaths;
fs::path directory(this->basedir + "/data");
Payload::scan_dir_recursively( directory, paths);
for (auto & path : paths) {
if (fs::is_regular_file( path )) {
strpaths.push_back( path.string() );
if (fs::is_directory( directory )) {
Payload::scan_dir_recursively( directory, paths);
for (auto & path : paths) {
if (fs::is_regular_file( path )) {
strpaths.push_back( path.string() );
}
}
}
return strpaths;
}
bool Payload::validate() {
return true;
fs::path directory(this->basedir + "/data");
return fs::is_directory( directory );
}
bool Payload::store( const string& basedir ) {
string newbasedir = basedir + "data/";
fs::path p{ newbasedir };
fs::file_status s = fs::status( p );
if (fs::is_directory( s)) {

Loading…
Cancel
Save