mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 20:26:30 +01:00
Use PBD::find_files_matching_pattern instead of other variations
This commit is contained in:
parent
36fd67ab72
commit
8d0cba3384
11 changed files with 26 additions and 107 deletions
|
|
@ -507,14 +507,14 @@ AudioEngine::discover_backends ()
|
||||||
Glib::PatternSpec dll_extension_pattern("*backend.dll");
|
Glib::PatternSpec dll_extension_pattern("*backend.dll");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
find_matching_files_in_search_path (backend_search_path (),
|
find_files_matching_pattern (backend_modules, backend_search_path (),
|
||||||
so_extension_pattern, backend_modules);
|
so_extension_pattern);
|
||||||
|
|
||||||
find_matching_files_in_search_path (backend_search_path (),
|
find_files_matching_pattern (backend_modules, backend_search_path (),
|
||||||
dylib_extension_pattern, backend_modules);
|
dylib_extension_pattern);
|
||||||
|
|
||||||
find_matching_files_in_search_path (backend_search_path (),
|
find_files_matching_pattern (backend_modules, backend_search_path (),
|
||||||
dll_extension_pattern, backend_modules);
|
dll_extension_pattern);
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::AudioEngine, string_compose ("looking for backends in %1\n", backend_search_path().to_string()));
|
DEBUG_TRACE (DEBUG::AudioEngine, string_compose ("looking for backends in %1\n", backend_search_path().to_string()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -268,14 +268,14 @@ ControlProtocolManager::discover_control_protocols ()
|
||||||
Glib::PatternSpec so_extension_pattern("*.so");
|
Glib::PatternSpec so_extension_pattern("*.so");
|
||||||
Glib::PatternSpec dylib_extension_pattern("*.dylib");
|
Glib::PatternSpec dylib_extension_pattern("*.dylib");
|
||||||
|
|
||||||
find_matching_files_in_search_path (control_protocol_search_path (),
|
find_files_matching_pattern (cp_modules, control_protocol_search_path (),
|
||||||
dll_extension_pattern, cp_modules);
|
dll_extension_pattern);
|
||||||
|
|
||||||
find_matching_files_in_search_path (control_protocol_search_path (),
|
find_files_matching_pattern (cp_modules, control_protocol_search_path (),
|
||||||
so_extension_pattern, cp_modules);
|
so_extension_pattern);
|
||||||
|
|
||||||
find_matching_files_in_search_path (control_protocol_search_path (),
|
find_files_matching_pattern (cp_modules, control_protocol_search_path (),
|
||||||
dylib_extension_pattern, cp_modules);
|
dylib_extension_pattern);
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::ControlProtocols,
|
DEBUG_TRACE (DEBUG::ControlProtocols,
|
||||||
string_compose (_("looking for control protocols in %1\n"), control_protocol_search_path().to_string()));
|
string_compose (_("looking for control protocols in %1\n"), control_protocol_search_path().to_string()));
|
||||||
|
|
|
||||||
|
|
@ -332,8 +332,7 @@ ExportProfileManager::find_file (std::string const & pattern)
|
||||||
{
|
{
|
||||||
vector<std::string> found;
|
vector<std::string> found;
|
||||||
|
|
||||||
Glib::PatternSpec pattern_spec (pattern);
|
find_files_matching_pattern (found, search_path, pattern);
|
||||||
find_matching_files_in_search_path (search_path, pattern_spec, found);
|
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -404,11 +404,9 @@ ARDOUR::find_bindings_files (map<string,string>& files)
|
||||||
Searchpath spath = ardour_config_search_path();
|
Searchpath spath = ardour_config_search_path();
|
||||||
|
|
||||||
if (getenv ("ARDOUR_SAE")) {
|
if (getenv ("ARDOUR_SAE")) {
|
||||||
Glib::PatternSpec pattern("*SAE-*.bindings");
|
find_files_matching_pattern (found, spath, "*SAE-*.bindings");
|
||||||
find_matching_files_in_search_path (spath, pattern, found);
|
|
||||||
} else {
|
} else {
|
||||||
Glib::PatternSpec pattern("*.bindings");
|
find_files_matching_pattern (found, spath, "*.bindings");
|
||||||
find_matching_files_in_search_path (spath, pattern, found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found.empty()) {
|
if (found.empty()) {
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,9 @@ MidiPatchManager::add_session_patches ()
|
||||||
|
|
||||||
assert (Glib::file_test (path_to_patches, Glib::FILE_TEST_IS_DIR));
|
assert (Glib::file_test (path_to_patches, Glib::FILE_TEST_IS_DIR));
|
||||||
|
|
||||||
Glib::PatternSpec pattern(string("*.midnam"));
|
|
||||||
vector<std::string> result;
|
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;
|
info << "Loading " << result.size() << " MIDI patches from " << path_to_patches << endmsg;
|
||||||
|
|
||||||
|
|
@ -104,10 +103,9 @@ MidiPatchManager::refresh()
|
||||||
_all_models.clear();
|
_all_models.clear();
|
||||||
|
|
||||||
Searchpath search_path = midi_patch_search_path ();
|
Searchpath search_path = midi_patch_search_path ();
|
||||||
Glib::PatternSpec pattern (string("*.midnam"));
|
|
||||||
vector<std::string> result;
|
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;
|
info << "Loading " << result.size() << " MIDI patches from " << search_path.to_string() << endmsg;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,18 +326,9 @@ PluginManager::ladspa_refresh ()
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::PluginManager, string_compose ("LADSPA: search along: [%1]\n", ladspa_search_path().to_string()));
|
DEBUG_TRACE (DEBUG::PluginManager, string_compose ("LADSPA: search along: [%1]\n", ladspa_search_path().to_string()));
|
||||||
|
|
||||||
Glib::PatternSpec so_extension_pattern("*.so");
|
find_files_matching_pattern (ladspa_modules, ladspa_search_path (), "*.so");
|
||||||
Glib::PatternSpec dylib_extension_pattern("*.dylib");
|
find_files_matching_pattern (ladspa_modules, ladspa_search_path (), "*.dylib");
|
||||||
Glib::PatternSpec dll_extension_pattern("*.dll");
|
find_files_matching_pattern (ladspa_modules, ladspa_search_path (), "*.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);
|
|
||||||
|
|
||||||
for (vector<std::string>::iterator i = ladspa_modules.begin(); i != ladspa_modules.end(); ++i) {
|
for (vector<std::string>::iterator i = ladspa_modules.begin(); i != ladspa_modules.end(); ++i) {
|
||||||
ARDOUR::PluginScanMessage(_("LADSPA"), *i, false);
|
ARDOUR::PluginScanMessage(_("LADSPA"), *i, false);
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,8 @@ void
|
||||||
get_state_files_in_directory (const std::string & directory_path,
|
get_state_files_in_directory (const std::string & directory_path,
|
||||||
vector<std::string> & result)
|
vector<std::string> & result)
|
||||||
{
|
{
|
||||||
Glib::PatternSpec state_file_pattern('*' + string(statefile_suffix));
|
find_files_matching_pattern (result, directory_path,
|
||||||
|
'*' + string(statefile_suffix));
|
||||||
find_matching_files_in_directory (directory_path, state_file_pattern,
|
|
||||||
result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string>
|
vector<string>
|
||||||
|
|
|
||||||
|
|
@ -616,8 +616,7 @@ ARDOUR::get_jack_server_paths (const vector<std::string>& server_dir_paths,
|
||||||
vector<std::string>& server_paths)
|
vector<std::string>& server_paths)
|
||||||
{
|
{
|
||||||
for (vector<string>::const_iterator i = server_names.begin(); i != server_names.end(); ++i) {
|
for (vector<string>::const_iterator i = server_names.begin(); i != server_names.end(); ++i) {
|
||||||
Glib::PatternSpec ps (*i);
|
find_files_matching_pattern (server_paths, server_dir_paths, *i);
|
||||||
find_matching_files_in_directories (server_dir_paths, ps, server_paths);
|
|
||||||
}
|
}
|
||||||
return !server_paths.empty();
|
return !server_paths.empty();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ MidnamTest::load_all_midnams_test ()
|
||||||
Glib::PatternSpec pattern(string("*.midnam"));
|
Glib::PatternSpec pattern(string("*.midnam"));
|
||||||
vector<std::string> result;
|
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;
|
cout << "Loading " << result.size() << " MIDI patches from " << prefix << endl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,39 +146,14 @@ find_files_matching_pattern (vector<string>& result,
|
||||||
find_files_matching_pattern (result, paths, tmp);
|
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
|
bool
|
||||||
find_file_in_search_path(const Searchpath& search_path,
|
find_file_in_search_path(const Searchpath& search_path,
|
||||||
const string& filename,
|
const string& filename,
|
||||||
std::string& result)
|
std::string& result)
|
||||||
{
|
{
|
||||||
vector<std::string> tmp;
|
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)
|
if (tmp.size() == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -89,45 +89,6 @@ find_files_matching_pattern (std::vector<std::string>& result,
|
||||||
const Searchpath& paths,
|
const Searchpath& paths,
|
||||||
const std::string& pattern);
|
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
|
* 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.
|
* to that file in result if it is found within the search path.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue