X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fio%2Ffilesystem.hpp;h=d7fe184da71bf0be3c9898261184e5a853a055ab;hb=ce10bfbe252d5598bbb559c6ce55aed1b9393227;hp=2af55fcce265d866ef33139a470fb0555fc28cd3;hpb=ab5d0b96a74b0d8fb33a89c097ff9c7021349f56;p=blank.git diff --git a/src/io/filesystem.hpp b/src/io/filesystem.hpp index 2af55fc..d7fe184 100644 --- a/src/io/filesystem.hpp +++ b/src/io/filesystem.hpp @@ -42,6 +42,27 @@ bool remove_file(const std::string &); /// @return true if the directory was completely removed bool remove_dir(const std::string &); + +/// Create a temporary directory with lifetime tie to the instance's. +/// Note that the directory may survive its object if removal fails +/// for any reason, e.g. another process changing permissions. +class TempDir { + +public: + TempDir(); + ~TempDir(); + + TempDir(const TempDir &) = delete; + TempDir &operator =(const TempDir &) = delete; + +public: + const std::string &Path() const noexcept { return path; } + +private: + std::string path; + +}; + } #endif