Remove the last safe directory listing functions.

This commit is contained in:
Adam Reichold
2015-12-26 02:15:24 +01:00
parent 747a28014b
commit bcda68f6e0
7 changed files with 120 additions and 128 deletions

View File

@@ -542,11 +542,44 @@ void FileCatalog::closeDir ()
std::vector<Glib::ustring> FileCatalog::getFileList ()
{
std::vector<Glib::ustring> names;
Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path (selectedDirectory);
safe_build_file_list (dir, names, selectedDirectory, &(options.parsedExtensions));
// Issue 2406 std::sort (names.begin(), names.end());
std::set<Glib::ustring> extensions;
for (const auto& parsedExt : options.parsedExtensions) {
extensions.emplace (parsedExt.lowercase ());
}
try {
auto dir = Gio::File::create_for_path (selectedDirectory);
auto enumerator = dir->enumerate_children ();
while (auto file = enumerator->next_file ()) {
const Glib::ustring fname = file->get_name ();
auto lastdot = fname.find_last_of ('.');
if (lastdot >= fname.length () - 1) {
continue;
}
const auto fext = fname.substr (lastdot + 1).lowercase ();
if (extensions.count (fext) == 0) {
continue;
}
names.emplace_back (Glib::build_filename (selectedDirectory, fname));
}
} catch (Glib::Exception& exception) {
if (options.rtSettings.verbose) {
std::cerr << "Failed to list directory \"" << selectedDirectory << "\": " << exception.what() << std::endl;
}
}
return names;
}