paysages3d/src/core/FileSystem.cpp

30 lines
680 B
C++

#include "FileSystem.h"
#include <filesystem>
using namespace std::filesystem;
string FileSystem::getTempFile(const string &filename) {
const auto temp_dir = temp_directory_path() / path("paysages3d");
if (!exists(temp_dir)) {
create_directory(temp_dir);
}
return temp_dir / path(filename);
}
bool FileSystem::isFile(const string &filepath) {
const auto path(filepath);
return exists(path) && is_regular_file(path);
}
bool FileSystem::removeFile(const string &filepath) {
const auto path(filepath);
if (exists(path) && is_regular_file(path)) {
remove(filepath);
return true;
} else {
return false;
}
}