Change PBD::get_files_in_directory to return full paths in result
authorTim Mayberry <mojofunk@gmail.com>
Thu, 19 Jun 2014 02:33:14 +0000 (12:33 +1000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Jun 2014 16:40:09 +0000 (12:40 -0400)
get_files_in_directory uses get_directory_contents internally now

gtk2_ardour/utils.cc
libs/pbd/file_utils.cc

index 82397a325d7dc1732f6287ddbfb6dec9a52c6217..c3d02dee2fa897f03d4f81cc0444fd58d03d285b 100644 (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)));
                        }
                }
        }
index bdc03dc143a6a4adcd21ca203c1381ea9d7ef29b..6e81a213f5f41359e993f4189f5ea75bf8860c98 100644 (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);
        }
 }