summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-09-27 12:44:54 +0200
committerRobin Gareus <robin@gareus.org>2015-09-27 12:44:54 +0200
commite344d379d274f91850e8ca7c0f450a82b3c04c86 (patch)
treea966fe2b0190e84d3453fda887fec6960a754072
parentcf761d4f67d04970604948caa860ce193695dc1c (diff)
update semantics of PBD::remove_directory()
Remove the directory recursively including itself. The function is used in two places only: * LV2Plugin::add_state() -- no change, remove tmp. state * Session::save_as() -- on error, remove target In both cases removing the folder itself is correct.
-rw-r--r--libs/pbd/file_utils.cc1
-rw-r--r--libs/pbd/pbd/file_utils.h4
-rw-r--r--libs/pbd/test/filesystem_test.cc9
3 files changed, 4 insertions, 10 deletions
diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc
index 950880c0bf..3cd0689f4b 100644
--- a/libs/pbd/file_utils.cc
+++ b/libs/pbd/file_utils.cc
@@ -476,6 +476,7 @@ void
remove_directory (const std::string& dir)
{
remove_directory_internal (dir, 0, 0, false);
+ g_rmdir (dir.c_str());
}
string
diff --git a/libs/pbd/pbd/file_utils.h b/libs/pbd/pbd/file_utils.h
index b55b9fd4e4..876f1148d5 100644
--- a/libs/pbd/pbd/file_utils.h
+++ b/libs/pbd/pbd/file_utils.h
@@ -235,9 +235,9 @@ LIBPBD_API int clear_directory (const std::string& dir, size_t* size = 0,
/**
* Remove all the contents of a directory recursively.
- * @note dir will not be removed
+ * including the dir itself (`rm -rf $dir`)
*
- * @param dir The directory to remove files from.
+ * @param dir The directory to remove recursively
*/
LIBPBD_API void remove_directory (const std::string& dir);
diff --git a/libs/pbd/test/filesystem_test.cc b/libs/pbd/test/filesystem_test.cc
index 1eaba54968..ccd4deab65 100644
--- a/libs/pbd/test/filesystem_test.cc
+++ b/libs/pbd/test/filesystem_test.cc
@@ -335,14 +335,7 @@ FilesystemTest::testRemoveDirectory ()
PBD::remove_directory (output_dir_path);
- // doesn't actually remove directory though...just contents
- CPPUNIT_ASSERT (Glib::file_test (output_dir_path, Glib::FILE_TEST_IS_DIR));
-
- files_in_output_dir.clear ();
-
- PBD::get_paths (files_in_output_dir, output_dir_path, false, true);
-
- CPPUNIT_ASSERT (files_in_output_dir.size () == 0);
+ CPPUNIT_ASSERT (!Glib::file_test (output_dir_path, Glib::FILE_TEST_EXISTS));
}
void