diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-07-02 14:49:36 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-07-02 14:49:36 +0000 |
| commit | 7a3a974807f116c98c54bfb8b458207ed406f72d (patch) | |
| tree | b2bde20ab14176998f61688d116b74ff7b06b793 /src/io/resource.cpp | |
| parent | Merge https://gitlab.com/inkscape/inkscape into selectable-knots (diff) | |
| parent | Move directory scanners to new get_filenames(...) calls (diff) | |
| download | inkscape-7a3a974807f116c98c54bfb8b458207ed406f72d.tar.gz inkscape-7a3a974807f116c98c54bfb8b458207ed406f72d.zip | |
Merge https://gitlab.com/inkscape/inkscape into selectable-knots
Diffstat (limited to 'src/io/resource.cpp')
| -rw-r--r-- | src/io/resource.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/io/resource.cpp b/src/io/resource.cpp index 6a388c1ac..aa13de683 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -205,7 +205,7 @@ std::vector<Glib::ustring> get_filenames(Domain domain, Type type, std::vector<c * * &files - Output list to populate * path - The directory to parse, will add nothing if directory doesn't exist - * extensions - Only add files with these extensions. + * extensions - Only add files with these extensions, they must be duplicated * exclusions - Exclude files that exactly match these names. */ void get_filenames_from_path(std::vector<Glib::ustring> &files, Glib::ustring path, std::vector<const char *> extensions, std::vector<const char *> exclusions) @@ -217,15 +217,23 @@ void get_filenames_from_path(std::vector<Glib::ustring> &files, Glib::ustring pa Glib::Dir dir(path); std::string file = dir.read_name(); while (!file.empty()){ - bool reject = false; + // If not extensions are specified, don't reject ANY files. + bool reject = !extensions.empty(); + + // Unreject any file which has one of the extensions. for (auto &ext: extensions) { - reject |= !Glib::str_has_suffix(file, ext); + reject ^= Glib::str_has_suffix(file, ext); } + + // Reject any file which matches the exclusions. for (auto &exc: exclusions) { reject |= Glib::str_has_prefix(file, exc); } + + // Reject any filename which isn't a regular file Glib::ustring filename = Glib::build_filename(path, file); reject |= !Glib::file_test(filename, Glib::FILE_TEST_IS_REGULAR); + if(!reject) { files.push_back(filename); } |
