Use PBD::find_files_matching_pattern instead of other variations
authorTim Mayberry <mojofunk@gmail.com>
Tue, 24 Jun 2014 00:30:22 +0000 (10:30 +1000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Jun 2014 16:40:10 +0000 (12:40 -0400)
libs/ardour/audioengine.cc
libs/ardour/control_protocol_manager.cc
libs/ardour/export_profile_manager.cc
libs/ardour/globals.cc
libs/ardour/midi_patch_manager.cc
libs/ardour/plugin_manager.cc
libs/ardour/session_state_utils.cc
libs/backends/jack/jack_utils.cc
libs/midi++2/test/MidnamTest.cpp
libs/pbd/file_utils.cc
libs/pbd/pbd/file_utils.h

index 8612f44b8aa280803b3e2502e76f3e64adf6ebe4..6c9fd442fbc4c45783769872b16cf4be274dc166 100644 (file)
@@ -506,15 +506,15 @@ AudioEngine::discover_backends ()
 #else
        Glib::PatternSpec dll_extension_pattern("*backend.dll");
 #endif
-       
-       find_matching_files_in_search_path (backend_search_path (),
-                                           so_extension_pattern, backend_modules);
 
-       find_matching_files_in_search_path (backend_search_path (),
-                                           dylib_extension_pattern, backend_modules);
+       find_files_matching_pattern (backend_modules, backend_search_path (),
+                                    so_extension_pattern);
+
+       find_files_matching_pattern (backend_modules, backend_search_path (),
+                                    dylib_extension_pattern);
 
-       find_matching_files_in_search_path (backend_search_path (),
-                                           dll_extension_pattern, backend_modules);
+       find_files_matching_pattern (backend_modules, backend_search_path (),
+                                    dll_extension_pattern);
 
        DEBUG_TRACE (DEBUG::AudioEngine, string_compose ("looking for backends in %1\n", backend_search_path().to_string()));
 
index 49b3d0776161c6ecfe2b99473c194ad151905bd5..fdac48e731124aa8620be3913c68bb239c8c6d6e 100644 (file)
@@ -268,14 +268,14 @@ ControlProtocolManager::discover_control_protocols ()
        Glib::PatternSpec so_extension_pattern("*.so");
        Glib::PatternSpec dylib_extension_pattern("*.dylib");
 
-       find_matching_files_in_search_path (control_protocol_search_path (),
-                                           dll_extension_pattern, cp_modules);
+       find_files_matching_pattern (cp_modules, control_protocol_search_path (),
+                                    dll_extension_pattern);
 
-       find_matching_files_in_search_path (control_protocol_search_path (),
-                                           so_extension_pattern, cp_modules);
+       find_files_matching_pattern (cp_modules, control_protocol_search_path (),
+                                    so_extension_pattern);
 
-       find_matching_files_in_search_path (control_protocol_search_path (),
-                                           dylib_extension_pattern, cp_modules);
+       find_files_matching_pattern (cp_modules, control_protocol_search_path (),
+                                    dylib_extension_pattern);
 
        DEBUG_TRACE (DEBUG::ControlProtocols, 
                     string_compose (_("looking for control protocols in %1\n"), control_protocol_search_path().to_string()));
index 0792232b5fc0edb60e8d45773e51762c5f7760aa..4a10d3dfa832b035e220d171f164f4ff1ae0b0f6 100644 (file)
@@ -332,8 +332,7 @@ ExportProfileManager::find_file (std::string const & pattern)
 {
        vector<std::string> found;
 
-       Glib::PatternSpec pattern_spec (pattern);
-       find_matching_files_in_search_path (search_path, pattern_spec, found);
+       find_files_matching_pattern (found, search_path, pattern);
 
        return found;
 }
index 054ffffe51df8408bb0935add74ee4940b82ac61..ed62420ff07e7055cb69d7cec3aeb742daee2060 100644 (file)
@@ -404,11 +404,9 @@ ARDOUR::find_bindings_files (map<string,string>& files)
        Searchpath spath = ardour_config_search_path();
 
        if (getenv ("ARDOUR_SAE")) {
-               Glib::PatternSpec pattern("*SAE-*.bindings");
-               find_matching_files_in_search_path (spath, pattern, found);
+               find_files_matching_pattern (found, spath, "*SAE-*.bindings");
        } else {
-               Glib::PatternSpec pattern("*.bindings");
-               find_matching_files_in_search_path (spath, pattern, found);
+               find_files_matching_pattern (found, spath, "*.bindings");
        }
 
        if (found.empty()) {
index 4587b1aad9d483243f963ffa14b467eb04db553c..591c0cae40909743725d10976dc00bc0508db9c3 100644 (file)
@@ -68,10 +68,9 @@ MidiPatchManager::add_session_patches ()
 
        assert (Glib::file_test (path_to_patches, Glib::FILE_TEST_IS_DIR));
 
-       Glib::PatternSpec pattern(string("*.midnam"));
        vector<std::string> result;
 
-       find_matching_files_in_directory (path_to_patches, pattern, result);
+       find_files_matching_pattern (result, path_to_patches, "*.midnam");
 
        info << "Loading " << result.size() << " MIDI patches from " << path_to_patches << endmsg;
 
@@ -104,10 +103,9 @@ MidiPatchManager::refresh()
        _all_models.clear();
 
        Searchpath search_path = midi_patch_search_path ();
-       Glib::PatternSpec pattern (string("*.midnam"));
        vector<std::string> result;
 
-       find_matching_files_in_search_path (search_path, pattern, result);
+       find_files_matching_pattern (result, search_path, "*.midnam");
 
        info << "Loading " << result.size() << " MIDI patches from " << search_path.to_string() << endmsg;
 
index 0684009935183af2c4f82f0d27c432945ee44541..5c809c213bbfd61efd02ea357797a33700d3bc24 100644 (file)
@@ -326,18 +326,9 @@ PluginManager::ladspa_refresh ()
 
        DEBUG_TRACE (DEBUG::PluginManager, string_compose ("LADSPA: search along: [%1]\n", ladspa_search_path().to_string()));
 
-       Glib::PatternSpec so_extension_pattern("*.so");
-       Glib::PatternSpec dylib_extension_pattern("*.dylib");
-       Glib::PatternSpec dll_extension_pattern("*.dll");
-
-       find_matching_files_in_search_path (ladspa_search_path (),
-                                           so_extension_pattern, ladspa_modules);
-
-       find_matching_files_in_search_path (ladspa_search_path (),
-                                           dylib_extension_pattern, ladspa_modules);
-
-       find_matching_files_in_search_path (ladspa_search_path (),
-                                           dll_extension_pattern, ladspa_modules);
+       find_files_matching_pattern (ladspa_modules, ladspa_search_path (), "*.so");
+       find_files_matching_pattern (ladspa_modules, ladspa_search_path (), "*.dylib");
+       find_files_matching_pattern (ladspa_modules, ladspa_search_path (), "*.dll");
 
        for (vector<std::string>::iterator i = ladspa_modules.begin(); i != ladspa_modules.end(); ++i) {
                ARDOUR::PluginScanMessage(_("LADSPA"), *i, false);
index 13d65e5b3c404d42187905637269bd78a809bea6..5d5c9cc8df6eefd605da55d2c7fec17add13c7c4 100644 (file)
@@ -47,10 +47,8 @@ void
 get_state_files_in_directory (const std::string & directory_path,
                              vector<std::string> & result)
 {
-       Glib::PatternSpec state_file_pattern('*' + string(statefile_suffix));
-
-       find_matching_files_in_directory (directory_path, state_file_pattern,
-                       result);
+       find_files_matching_pattern (result, directory_path,
+                                    '*' + string(statefile_suffix));
 }
 
 vector<string>
index 3bb06ee4e8640f05a0f42d4f4ed238dcf7fc3d72..8bbfab5cf1fb5c53b6097b215c2a55c103d72be2 100644 (file)
@@ -616,8 +616,7 @@ ARDOUR::get_jack_server_paths (const vector<std::string>& server_dir_paths,
                vector<std::string>& server_paths)
 {
        for (vector<string>::const_iterator i = server_names.begin(); i != server_names.end(); ++i) {
-                Glib::PatternSpec ps (*i);
-               find_matching_files_in_directories (server_dir_paths, ps, server_paths);
+               find_files_matching_pattern (server_paths, server_dir_paths, *i);
        }
        return !server_paths.empty();
 }
index d8c89eb011c3c921eb5923ff5c00ff0e0124f0db..52bf988e9be4debc1465efd85c832b722784d262 100644 (file)
@@ -160,7 +160,7 @@ MidnamTest::load_all_midnams_test ()
     Glib::PatternSpec pattern(string("*.midnam"));
     vector<std::string> result;
 
-    PBD::find_matching_files_in_directory (prefix, pattern, result);
+    PBD::find_files_matching_pattern (result, prefix, pattern);
 
     cout << "Loading " << result.size() << " MIDI patches from " << prefix << endl;
 
index 98c8a6fcfc3663dffe85abd8fe912659e8362478..bc4ad8ee6d2818a667cbf3f5f6be8e0822e1404d 100644 (file)
@@ -146,39 +146,14 @@ find_files_matching_pattern (vector<string>& result,
        find_files_matching_pattern (result, paths, tmp);
 }
 
-void
-find_matching_files_in_directory (const std::string& directory,
-                                  const Glib::PatternSpec& pattern,
-                                  vector<std::string>& result)
-{
-       find_files_matching_pattern (result, directory, pattern);
-}
-
-void
-find_matching_files_in_directories (const vector<std::string>& paths,
-                                    const Glib::PatternSpec& pattern,
-                                    vector<std::string>& result)
-{
-       find_files_matching_pattern (result, paths, pattern);
-}
-
-void
-find_matching_files_in_search_path (const Searchpath& search_path,
-                                    const Glib::PatternSpec& pattern,
-                                    vector<std::string>& result)
-{
-       find_files_matching_pattern (result, search_path, pattern);
-}
-
 bool
 find_file_in_search_path(const Searchpath& search_path,
                          const string& filename,
                          std::string& result)
 {
        vector<std::string> tmp;
-       Glib::PatternSpec tmp_pattern(filename);
 
-       find_matching_files_in_search_path (search_path, tmp_pattern, tmp);
+       find_files_matching_pattern (tmp, search_path, filename);
 
        if (tmp.size() == 0)
        {
index 588e48217a89ee9f08c2cab9d8db529b7e3e5c19..8fef0c4d45b3a1b974b88cebe4b37c1253bf038d 100644 (file)
@@ -89,45 +89,6 @@ find_files_matching_pattern (std::vector<std::string>& result,
                              const Searchpath& paths,
                              const std::string& pattern);
 
-/**
- * Takes a directory path and returns all the files in the directory
- * matching a particular pattern.
- *
- * @param directory A directory path
- * @param pattern A Glib::PatternSpec used to match the files.
- * @param result A vector in which to place the resulting matches.
- */
-LIBPBD_API void
-find_matching_files_in_directory (const std::string& directory,
-                                  const Glib::PatternSpec& pattern,
-                                  std::vector<std::string>& result);
-
-/**
- * Takes a number of directory paths and returns all the files matching
- * a particular pattern.
- *
- * @param paths A vector containing the Absolute paths
- * @param pattern A Glib::PatternSpec used to match the files
- * @param result A vector in which to place the resulting matches.
- */
-LIBPBD_API void
-find_matching_files_in_directories (const std::vector<std::string>& directory_paths,
-                                    const Glib::PatternSpec& pattern,
-                                    std::vector<std::string>& result);
-
-/**
- * Takes a Searchpath and puts a list of all the files in the search path
- * that match pattern into the result vector.
- *
- * @param search_path A Searchpath
- * @param pattern A Glib::PatternSpec used to match the files
- * @param result A vector in which to place the resulting matches.
- */
-LIBPBD_API void
-find_matching_files_in_search_path (const Searchpath& search_path,
-                                    const Glib::PatternSpec& pattern,
-                                    std::vector<std::string>& result);
-
 /**
  * Takes a search path and a file name and place the full path
  * to that file in result if it is found within the search path.