You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
492 B
33 lines
492 B
#include "webfuse_provider/utils/tempdir.hpp"
|
|
|
|
#include <unistd.h>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <stdexcept>
|
|
|
|
namespace webfuse_test
|
|
{
|
|
|
|
TempDir::TempDir(char const * prefix)
|
|
{
|
|
asprintf(&path_, "/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_;
|
|
}
|
|
|
|
|
|
} |