diff options
| author | Martin Owens <doctormo@gmail.com> | 2017-07-02 14:47:03 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2017-07-02 14:47:03 +0000 |
| commit | 7dc5626af3eb924fa381c46491cd49178a78cd73 (patch) | |
| tree | e50a3b98ce1393b7a06efbd11425f8c458b0cbbb /src/io/resource.cpp | |
| parent | pyc files are generated when testing modules, ignore them (diff) | |
| download | inkscape-7dc5626af3eb924fa381c46491cd49178a78cd73.tar.gz inkscape-7dc5626af3eb924fa381c46491cd49178a78cd73.zip | |
Move directory scanners to new get_filenames(...) calls
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); } |
