mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 09:06:33 +01:00
Add new function PBD::find_files_matching_pattern
This new function is intended to replace the three existing PBD::find_matching_files_* functions. The order of parameters matches find_files_matching_regex and find_files_matching_filter
This commit is contained in:
parent
d9a7d419b2
commit
077c09b105
2 changed files with 30 additions and 12 deletions
|
|
@ -110,14 +110,15 @@ get_files_in_directory (const std::string& directory_path, vector<string>& resul
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
find_matching_files_in_directory (const std::string& directory,
|
find_files_matching_pattern (vector<string>& result,
|
||||||
const Glib::PatternSpec& pattern,
|
const Searchpath& paths,
|
||||||
vector<std::string>& result)
|
const Glib::PatternSpec& pattern)
|
||||||
{
|
{
|
||||||
vector<string> tmp_files;
|
vector<string> tmp_files;
|
||||||
|
|
||||||
get_files_in_directory (directory, tmp_files);
|
for (vector<string>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
|
||||||
result.reserve(tmp_files.size());
|
get_files_in_directory (*i, tmp_files);
|
||||||
|
}
|
||||||
|
|
||||||
for (vector<string>::iterator file_iter = tmp_files.begin();
|
for (vector<string>::iterator file_iter = tmp_files.begin();
|
||||||
file_iter != tmp_files.end();
|
file_iter != tmp_files.end();
|
||||||
|
|
@ -133,6 +134,15 @@ find_matching_files_in_directory (const std::string& directory,
|
||||||
|
|
||||||
result.push_back(*file_iter);
|
result.push_back(*file_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
|
|
@ -140,12 +150,7 @@ find_matching_files_in_directories (const vector<std::string>& paths,
|
||||||
const Glib::PatternSpec& pattern,
|
const Glib::PatternSpec& pattern,
|
||||||
vector<std::string>& result)
|
vector<std::string>& result)
|
||||||
{
|
{
|
||||||
for (vector<std::string>::const_iterator path_iter = paths.begin();
|
find_files_matching_pattern (result, paths, pattern);
|
||||||
path_iter != paths.end();
|
|
||||||
++path_iter)
|
|
||||||
{
|
|
||||||
find_matching_files_in_directory (*path_iter, pattern, result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -153,7 +158,7 @@ find_matching_files_in_search_path (const Searchpath& search_path,
|
||||||
const Glib::PatternSpec& pattern,
|
const Glib::PatternSpec& pattern,
|
||||||
vector<std::string>& result)
|
vector<std::string>& result)
|
||||||
{
|
{
|
||||||
find_matching_files_in_directories (search_path, pattern, result);
|
find_files_matching_pattern (result, search_path, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,19 @@ LIBPBD_API void
|
||||||
get_files_in_directory (const std::string& path,
|
get_files_in_directory (const std::string& path,
|
||||||
std::vector<std::string>& result);
|
std::vector<std::string>& result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a Searchpath and returns all the files contained in the
|
||||||
|
* directory paths that match a particular pattern.
|
||||||
|
*
|
||||||
|
* @param result A vector in which to place the resulting matches.
|
||||||
|
* @param paths A Searchpath
|
||||||
|
* @param pattern A Glib::PatternSpec used to match the files.
|
||||||
|
*/
|
||||||
|
LIBPBD_API void
|
||||||
|
find_files_matching_pattern (std::vector<std::string>& result,
|
||||||
|
const Searchpath& paths,
|
||||||
|
const Glib::PatternSpec& pattern);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes a directory path and returns all the files in the directory
|
* Takes a directory path and returns all the files in the directory
|
||||||
* matching a particular pattern.
|
* matching a particular pattern.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue