1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/test/webfuse_provider/utils/tempdir.cc

33 lines
492 B
C++
Raw Normal View History

2020-06-16 21:39:45 +00:00
#include "webfuse_provider/utils/tempdir.hpp"
2020-02-16 13:47:21 +00:00
#include <unistd.h>
#include <cstdio>
2020-02-16 13:47:21 +00:00
#include <cstdlib>
#include <stdexcept>
namespace webfuse_test
{
TempDir::TempDir(char const * prefix)
{
asprintf(&path_, "/tmp/%s_XXXXXX", prefix);
2020-02-16 13:47:21 +00:00
char * result = mkdtemp(path_);
if (NULL == result)
{
throw std::runtime_error("unable to create temp dir");
}
}
TempDir::~TempDir()
{
rmdir(path_);
free(path_);
}
char const * TempDir::path()
{
return path_;
}
}