Browse Source

- added directory check

master
Andreas Romeyke 2 years ago
parent
commit
40140264d3
1 changed files with 16 additions and 11 deletions
  1. +16
    -11
      src/lib/payload.cpp

+ 16
- 11
src/lib/payload.cpp View File

@@ -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