namespace PBD {
+void
+get_directory_contents (const std::string& directory_path,
+ vector<string>& result,
+ bool files_only,
+ bool recurse)
+{
+ // perhaps we don't need this check assuming an exception is thrown
+ // as it would save checking that the path is a directory twice when
+ // recursing
+ if (!Glib::file_test (directory_path, Glib::FILE_TEST_IS_DIR)) return;
+
+ try
+ {
+ Glib::Dir dir(directory_path);
+ Glib::DirIterator i = dir.begin();
+
+ while (i != dir.end()) {
+
+ string fullpath = Glib::build_filename (directory_path, *i);
+
+ bool is_dir = Glib::file_test (fullpath, Glib::FILE_TEST_IS_DIR);
+
+ if (is_dir && recurse) {
+ get_directory_contents (fullpath, result, files_only, recurse);
+ }
+
+ i++;
+
+ if (is_dir && files_only) {
+ continue;
+ }
+ result.push_back (fullpath);
+ }
+ }
+ catch (Glib::FileError& err)
+ {
+ warning << err.what() << endmsg;
+ }
+}
+
void
get_files_in_directory (const std::string& directory_path, vector<string>& result)
{
namespace PBD {
+/**
+ * Get a contents of directory.
+ * @note paths in result will be absolute
+ *
+ * @param path An absolute path to a directory in the filename encoding
+ * @param result A vector of absolute paths to the directory entries in filename
+ * encoding.
+ * @param files_only Only include file entries in result
+ * @param recurse Recurse into child directories
+ */
+LIBPBD_API void
+get_directory_contents (const std::string& path,
+ std::vector<std::string>& result,
+ bool files_only = true,
+ bool recurse = false);
+
/**
* Get a list of files in a directory.
* @note You must join path with result to get the absolute path