12#ifndef SST_CORE_FILESYSTEM_H
13#define SST_CORE_FILESYSTEM_H
35 Filesystem() =
default;
132 FILE*
fopen(
const std::string& filename,
const char* mode);
168 std::ofstream
ofstream(
const std::string& filename, std::ios_base::openmode mode = std::ios_base::out);
203 static std::string
getAbsolutePath(
const std::string& path, std::string base_path);
212 std::filesystem::path base_path_;
213 static std::mutex create_mutex_;
216void test_filesystem();
bool ensureDirectoryExists(std::filesystem::path p, bool strip_filename=false)
This function will ensure a directory exists, and if it doesn't already exist, it will create it.
Definition filesystem.cc:144
std::string createUniqueDirectory(std::filesystem::path dir_name)
Creates a unique directory.
Definition filesystem.cc:168
FILE * fopen(const std::string &filename, const char *mode)
Open a file using std::fopen().
Definition filesystem.cc:209
static std::string getRandomName(size_t length=8)
Gets a random file name for use as a temporary file or directory.
Definition filesystem.cc:265
bool setBasePath(const std::string &base_path)
Set the base path to be use when relative paths are used.
Definition filesystem.cc:102
std::ofstream ofstream(const std::string &filename, std::ios_base::openmode mode=std::ios_base::out)
Open a file using ofstream.
Definition filesystem.cc:217
std::string getAbsolutePath(const std::string &path)
Get the absolute path for a directory or name.
Definition filesystem.cc:199
std::string getBasePath() const
Get the base_path set by setBasePath.
Definition filesystem.h:177