fs/tmp: add forgotten test suite
This commit is contained in:
parent
9b11cc92ff
commit
ff1ed506bd
@ -18,7 +18,6 @@ cruft::fs::mktmpdir (void)
|
|||||||
{
|
{
|
||||||
// The pattern suffix we'll append to the temp directory.
|
// The pattern suffix we'll append to the temp directory.
|
||||||
//
|
//
|
||||||
// * It needs a slash to ensure we don't try to create a new directory.
|
|
||||||
// * We might as well append the package name for clarity
|
// * We might as well append the package name for clarity
|
||||||
// * The libc call REQUIRES the string end with "XXXXXX"
|
// * The libc call REQUIRES the string end with "XXXXXX"
|
||||||
char const SUFFIX[] = "/" PACKAGE_NAME "-XXXXXX";
|
char const SUFFIX[] = "/" PACKAGE_NAME "-XXXXXX";
|
||||||
@ -26,11 +25,11 @@ cruft::fs::mktmpdir (void)
|
|||||||
auto const root = cruft::paths::temp ();
|
auto const root = cruft::paths::temp ();
|
||||||
std::string path;
|
std::string path;
|
||||||
path.reserve (root.string ().size () + sizeof (SUFFIX));
|
path.reserve (root.string ().size () + sizeof (SUFFIX));
|
||||||
path = root.string ();
|
path = root.string ();
|
||||||
path += SUFFIX;
|
path += SUFFIX;
|
||||||
|
|
||||||
if (!mkdtemp (path.data ()))
|
if (!mkdtemp (path.data ()))
|
||||||
cruft::posix::error::throw_code ();
|
cruft::posix::error::throw_code ();
|
||||||
|
|
||||||
return path;
|
return std::filesystem::path (path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user