From 811d4229c196c1c98ff865fdfd981ef2908f6d8b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 21 Jul 2017 09:36:05 +0200 Subject: Improve auto_rm --- libbutl/filesystem.ixx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libbutl/filesystem.ixx') 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 inline auto_rm

:: auto_rm (auto_rm&& x) - : path_ (std::move (x.path_)) + : path (std::move (x.path)), active (x.active) { - x.cancel (); + x.active = false; } template @@ -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:: - ~auto_rm () {if (!path_.empty ()) try_rmfile (path_, true);} + ~auto_rm () {if (active && !path.empty ()) try_rmfile (path, true);} template <> inline auto_rm:: - ~auto_rm () {if (!path_.empty ()) try_rmdir_r (path_, true);} + ~auto_rm () {if (active && !path.empty ()) try_rmdir_r (path, true);} // cpflags // -- cgit v1.1