MeshLib C++ Docs
Loading...
Searching...
No Matches
MRUniqueTemporaryFolder.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4
5#include <filesystem>
6
7namespace MR
8{
9
11using FolderCallback = std::function<void( const std::filesystem::path& tempFolderName )>;
12
15{
16public:
18 MRMESH_API UniqueTemporaryFolder( FolderCallback onPreTempFolderDelete = {} );
19
22
23 explicit operator bool() const
24 {
25 return !folder_.empty();
26 }
27 operator const std::filesystem::path& ( ) const
28 {
29 return folder_;
30 }
31 std::filesystem::path operator /( const std::filesystem::path& child ) const
32 {
33 return folder_ / child;
34 }
35
36private:
37 std::filesystem::path folder_;
38 FolderCallback onPreTempFolderDelete_;
39};
40
41} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
helper class to create a temporary folder; the folder will be removed on the object's destruction
Definition MRUniqueTemporaryFolder.h:15
MRMESH_API ~UniqueTemporaryFolder()
removes folder with all its content
std::filesystem::path operator/(const std::filesystem::path &child) const
Definition MRUniqueTemporaryFolder.h:31
MRMESH_API UniqueTemporaryFolder(FolderCallback onPreTempFolderDelete={})
creates new folder in temp directory
Definition MRCameraOrientationPlugin.h:8
std::function< void(const std::filesystem::path &tempFolderName)> FolderCallback
this callback will be called before compression on serialization and after decompression on deseriali...
Definition MRUniqueTemporaryFolder.h:11