diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-07-21 09:36:05 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-07-21 09:36:05 +0200 |
commit | 811d4229c196c1c98ff865fdfd981ef2908f6d8b (patch) | |
tree | 7ed4833d43b575b64ebb4e300a37320e6230d8b3 /libbutl/filesystem.ixx | |
parent | 41da9fabee47c81c1c8f59fe6616f24fc1b21294 (diff) |
Improve auto_rm
Diffstat (limited to 'libbutl/filesystem.ixx')
-rw-r--r-- | libbutl/filesystem.ixx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libbutl/filesystem.ixx b/libbutl/filesystem.ixx index a53aa47..a618d5b 100644 --- a/libbutl/filesystem.ixx +++ b/libbutl/filesystem.ixx @@ -44,9 +44,9 @@ namespace butl template <typename P> inline auto_rm<P>:: auto_rm (auto_rm&& x) - : path_ (std::move (x.path_)) + : path (std::move (x.path)), active (x.active) { - x.cancel (); + x.active = false; } template <typename P> @@ -55,8 +55,9 @@ namespace butl { if (this != &x) { - path_ = std::move (x.path_); - x.cancel (); + path = std::move (x.path); + active = x.active; + x.active = false; } return *this; @@ -64,11 +65,11 @@ namespace butl template <> inline auto_rm<path>:: - ~auto_rm () {if (!path_.empty ()) try_rmfile (path_, true);} + ~auto_rm () {if (active && !path.empty ()) try_rmfile (path, true);} template <> inline auto_rm<dir_path>:: - ~auto_rm () {if (!path_.empty ()) try_rmdir_r (path_, true);} + ~auto_rm () {if (active && !path.empty ()) try_rmdir_r (path, true);} // cpflags // |