From 8a82f67e2cb3366ab6988bcb56eb06c1d56fdc5d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 28 Apr 2018 18:04:08 +0200 Subject: Use rmsymlink() to portably remove symlinks --- build2/filesystem.cxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'build2/filesystem.cxx') diff --git a/build2/filesystem.cxx b/build2/filesystem.cxx index 58e3037..bfda1c4 100644 --- a/build2/filesystem.cxx +++ b/build2/filesystem.cxx @@ -85,6 +85,33 @@ namespace build2 return ms; } + fs_status + rmsymlink (const path& p, bool d, uint16_t v) + { + auto print = [&p, v] () + { + if (verb >= v) + text << "rm " << p.string (); + }; + + rmfile_status rs; + + try + { + rs = try_rmsymlink (p, d); + } + catch (const system_error& e) + { + print (); + fail << "unable to remove symlink " << p.string () << ": " << e << endf; + } + + if (rs == rmfile_status::success) + print (); + + return rs; + } + fs_status rmdir_r (const dir_path& d, bool dir, uint16_t v) { -- cgit v1.1