Browse Source

- using auto for iterators

master
Andreas Romeyke 3 years ago
parent
commit
e417c04e8a
1 changed files with 8 additions and 9 deletions
  1. +8
    -9
      src/lib/payload.cpp

+ 8
- 9
src/lib/payload.cpp View File

@ -19,7 +19,8 @@ Payload::Payload( string basedir ) {
};
void Payload::scan_dir_recursively( const fs::path& directory, list<fs::path> &paths) {
fs::recursive_directory_iterator iter(directory), end;
fs::recursive_directory_iterator iter(directory);
fs::recursive_directory_iterator end;
for (; iter != end; ++iter) {
fs::path subdir = iter->path();
paths.push_back( subdir );
@ -32,10 +33,9 @@ list<string> Payload::get_all_relative_paths() {
list<string> strpaths;
fs::path directory(this->basedir + "/data");
Payload::scan_dir_recursively( directory, paths);
list<fs::path>::iterator i;
for (i=paths.begin(); i!= paths.end(); i++) {
if (fs::is_regular_file( *i )) {
fs::path relpath = fs::relative((*i), this->basedir);
for (auto & path : paths) {
if (fs::is_regular_file( path )) {
fs::path relpath = fs::relative(path, this->basedir);
strpaths.push_back( relpath.string() );
}
}
@ -47,10 +47,9 @@ list<string> Payload::get_all_absolute_paths() {
list<string> strpaths;
fs::path directory(this->basedir + "/data");
Payload::scan_dir_recursively( directory, paths);
list<fs::path>::iterator i;
for (i=paths.begin(); i!= paths.end(); i++) {
if (fs::is_regular_file( *i )) {
strpaths.push_back( (*i).string() );
for (auto & path : paths) {
if (fs::is_regular_file( path )) {
strpaths.push_back( path.string() );
}
}
return strpaths;


Loading…
Cancel
Save