From 4a1d5f65c2682f7f4de2a288c411370ed868fa1c Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 4 Jul 2017 20:58:26 -0400 Subject: Make path scanning recursive, add ustring get_filenames and clean up --- src/io/resource.cpp | 28 ++++++++++++---------------- src/io/resource.h | 4 ++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/io/resource.cpp b/src/io/resource.cpp index aa13de683..7ecfceb81 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -199,11 +199,17 @@ std::vector get_filenames(Domain domain, Type type, std::vector get_filenames(Glib::ustring path, std::vector extensions, std::vector exclusions) +{ + std::vector ret; + get_filenames_from_path(ret, path, extensions, exclusions); + return ret; +} /* - * Get all the files from a specific path, populating &files vector + * Get all the files from a specific path and any sub-dirs, populating &files vector * - * &files - Output list to populate + * &files - Output list to populate, will be opoulated with full paths * path - The directory to parse, will add nothing if directory doesn't exist * extensions - Only add files with these extensions, they must be duplicated * exclusions - Exclude files that exactly match these names. @@ -232,9 +238,10 @@ void get_filenames_from_path(std::vector &files, Glib::ustring pa // 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) { + if(Glib::file_test(filename, Glib::FILE_TEST_IS_DIR)) { + get_filenames_from_path(files, filename, extensions, exclusions); + } else if(Glib::file_test(filename, Glib::FILE_TEST_IS_REGULAR) && !reject) { files.push_back(filename); } file = dir.read_name(); @@ -290,17 +297,6 @@ char *profile_path(const char *filename) prefdir = utf8Path; } } - - - /* not compiling yet... - - // Remember to free the list pointer - IMalloc * imalloc = 0; - if ( SHGetMalloc(&imalloc) == NOERROR) { - imalloc->lpVtbl->Free( imalloc, pidl ); - imalloc->lpVtbl->Release( imalloc ); - } - */ } if (prefdir) { @@ -345,7 +341,7 @@ char *profile_path(const char *filename) */ char *log_path(const char *filename) { - return profile_path(filename); + return profile_path(filename); } char *homedir_path(const char *filename) diff --git a/src/io/resource.h b/src/io/resource.h index ed877729c..861d380cb 100644 --- a/src/io/resource.h +++ b/src/io/resource.h @@ -72,6 +72,10 @@ std::vector get_filenames(Domain domain, Type type, std::vector extensions={}, std::vector exclusions={}); +std::vector get_filenames(Glib::ustring path, + std::vector extensions={}, + std::vector exclusions={}); + void get_filenames_from_path(std::vector &files, Glib::ustring path, std::vector extensions={}, -- cgit v1.2.3