fs/scoped: add scoped_dir convenience function

This commit is contained in:
Danny Robson 2022-09-27 14:55:49 +10:00
parent aca6d6fd08
commit 92dda992ee
2 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,7 @@
*/
#include "./scoped.hpp"
#include "./tmp.hpp"
#include <cruft/util/debug/assert.hpp>
@ -90,3 +91,11 @@ scoped_dir::scoped_dir (std::filesystem::path &&_path)
{
CHECK (std::filesystem::is_directory (get ()));
}
///////////////////////////////////////////////////////////////////////////////
cruft::fs::scoped_dir
cruft::fs::scoped_tmpdir ()
{
return scoped_dir (cruft::fs::mktmpdir ());
}

View File

@ -50,4 +50,8 @@ namespace cruft::fs {
using scoped_path::scoped_path;
};
/// A convenience function equivalent to `scoped_dir(maketmpdir())`
scoped_dir scoped_tmpdir (void);
}