1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-09-28 15:30:45 +00:00
falk-werner_webfuse-provider/test/webfuse/utils/tempdir.cc

33 lines
502 B
C++
Raw Normal View History

2020-02-16 13:47:21 +00:00
#include "webfuse/core/string.h"
2020-02-20 16:15:13 +00:00
#include "webfuse/utils/tempdir.hpp"
2020-02-16 13:47:21 +00:00
#include <unistd.h>
#include <cstdlib>
#include <stdexcept>
namespace webfuse_test
{
TempDir::TempDir(char const * prefix)
: path_(wf_create_string("/tmp/%s_XXXXXX", prefix))
{
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_;
}
}