Change PBD::get_files_in_directory to return full paths in result

get_files_in_directory uses get_directory_contents internally now
This commit is contained in:
Tim Mayberry 2014-06-19 12:33:14 +10:00 committed by Paul Davis
parent d1dd5d3ee7
commit 769ee5c1f2
2 changed files with 7 additions and 24 deletions

View File

@ -696,13 +696,8 @@ get_icon_sets ()
get_files_in_directory (*s, entries);
for (vector<string>::iterator e = entries.begin(); e != entries.end(); ++e) {
string d = *e;
Glib::ustring path = Glib::build_filename (*s, *e);
if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
r.push_back (Glib::filename_to_utf8 (*e));
if (Glib::file_test (*e, Glib::FILE_TEST_IS_DIR)) {
r.push_back (Glib::filename_to_utf8 (Glib::path_get_basename(*e)));
}
}
}

View File

@ -107,17 +107,7 @@ get_directory_contents (const std::string& directory_path,
void
get_files_in_directory (const std::string& directory_path, vector<string>& result)
{
if (!Glib::file_test (directory_path, Glib::FILE_TEST_IS_DIR)) return;
try
{
Glib::Dir dir(directory_path);
std::copy(dir.begin(), dir.end(), std::back_inserter(result));
}
catch (Glib::FileError& err)
{
warning << err.what() << endmsg;
}
return get_directory_contents (directory_path, result, true, false);
}
void
@ -134,17 +124,15 @@ find_matching_files_in_directory (const std::string& directory,
file_iter != tmp_files.end();
++file_iter)
{
if (!pattern.match(*file_iter)) continue;
std::string full_path(directory);
full_path = Glib::build_filename (full_path, *file_iter);
string filename = Glib::path_get_basename (*file_iter);
if (!pattern.match(filename)) continue;
DEBUG_TRACE (
DEBUG::FileUtils,
string_compose("Found file %1\n", full_path)
string_compose("Found file %1\n", *file_iter)
);
result.push_back(full_path);
result.push_back(*file_iter);
}
}