diff --git a/src/util/file.cpp b/src/util/file.cpp index 583f643..ee84c57 100644 --- a/src/util/file.cpp +++ b/src/util/file.cpp @@ -6,6 +6,7 @@ #include // assert #include // int32_t +#include #include // ifstream, ios, ofstream #include // make_unique #include @@ -43,6 +44,17 @@ File::~File() // ----------------------------------------- +File File::create(const std::string& path) +{ + if (!std::filesystem::exists(path)) { + std::ofstream { path }; + } + + return Util::File(path); +} + +// ----------------------------------------- + void File::clear() { m_data.clear(); diff --git a/src/util/file.h b/src/util/file.h index 62599c2..fcbb90b 100644 --- a/src/util/file.h +++ b/src/util/file.h @@ -16,6 +16,8 @@ public: File(const std::string& path); virtual ~File(); + static File create(const std::string& path); + void clear(); File& append(std::string data); File& replace(size_t index, size_t length, const std::string& data);