summaryrefslogtreecommitdiff
path: root/libcutl/cutl/fs/auto-remove.hxx
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2025-05-02 07:42:02 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-05-02 07:42:02 +0200
commitfc486627a4ecbae797fa6856d8a9204ea85f4db8 (patch)
treeff3dae4c0e5d980d8e2da4fc6256ae839269bbcd /libcutl/cutl/fs/auto-remove.hxx
parent1c188393cd2e271ed2581471b601fb5960777fd8 (diff)
parentecba0bbd9947036dd82f16ab95252f8db445e149 (diff)
Merge tag 'debian/4.0.0-10' into developdevelop
Bugfix release
Diffstat (limited to 'libcutl/cutl/fs/auto-remove.hxx')
-rw-r--r--libcutl/cutl/fs/auto-remove.hxx83
1 files changed, 83 insertions, 0 deletions
diff --git a/libcutl/cutl/fs/auto-remove.hxx b/libcutl/cutl/fs/auto-remove.hxx
new file mode 100644
index 0000000..c0319e8
--- /dev/null
+++ b/libcutl/cutl/fs/auto-remove.hxx
@@ -0,0 +1,83 @@
+// file : cutl/fs/auto-remove.hxx
+// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_FS_AUTO_REMOVE_HXX
+#define CUTL_FS_AUTO_REMOVE_HXX
+
+#include <vector>
+
+#include <cutl/fs/path.hxx>
+#include <cutl/fs/exception.hxx>
+
+#include <cutl/details/export.hxx>
+
+namespace cutl
+{
+ namespace fs
+ {
+ // Remove a file or an empty directory on destruction unless canceled.
+ //
+ struct LIBCUTL_EXPORT auto_remove
+ {
+ explicit
+ auto_remove (path const& p)
+ : path_ (p), canceled_ (false)
+ {
+ }
+
+ ~auto_remove ();
+
+ void
+ cancel ()
+ {
+ canceled_ = true;
+ }
+
+ private:
+ auto_remove (auto_remove const&);
+
+ auto_remove&
+ operator= (auto_remove const&);
+
+ private:
+ path path_;
+ bool canceled_;
+ };
+
+ // Remove a list of file or aempty directories on destruction unless
+ // canceled.
+ //
+ struct LIBCUTL_EXPORT auto_removes
+ {
+ auto_removes (): canceled_ (false) {}
+ ~auto_removes ();
+
+ void
+ add (path const& p)
+ {
+ paths_.push_back (p);
+ }
+
+ void
+ cancel ()
+ {
+ canceled_ = true;
+ }
+
+ private:
+ auto_removes (auto_removes const&);
+
+ auto_removes&
+ operator= (auto_removes const&);
+
+ private:
+ typedef std::vector<path> paths;
+
+ paths paths_;
+ bool canceled_;
+ };
+ }
+}
+
+#endif // CUTL_FS_AUTO_REMOVE_HXX