mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 07:14:56 +01:00
Add PBD::tmp_writable_directory utility function to pbd/file_utils.h/cc
This commit is contained in:
parent
2b03521ef9
commit
1abe8f4e42
2 changed files with 33 additions and 0 deletions
|
|
@ -468,4 +468,21 @@ remove_directory (const std::string& dir)
|
|||
remove_directory_internal (dir, 0, 0, false);
|
||||
}
|
||||
|
||||
string
|
||||
tmp_writable_directory (const char* domain, const string& prefix)
|
||||
{
|
||||
std::string tmp_dir = Glib::build_filename (g_get_tmp_dir(), domain);
|
||||
std::string dir_name;
|
||||
std::string new_test_dir;
|
||||
do {
|
||||
ostringstream oss;
|
||||
oss << prefix;
|
||||
oss << g_random_int ();
|
||||
dir_name = oss.str();
|
||||
new_test_dir = Glib::build_filename (tmp_dir, dir_name);
|
||||
if (Glib::file_test (new_test_dir, Glib::FILE_TEST_EXISTS)) continue;
|
||||
} while (g_mkdir_with_parents (new_test_dir.c_str(), 0755) != 0);
|
||||
return new_test_dir;
|
||||
}
|
||||
|
||||
} // namespace PBD
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue