diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-04-28 18:04:08 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-04-28 18:04:08 +0200 |
commit | 8a82f67e2cb3366ab6988bcb56eb06c1d56fdc5d (patch) | |
tree | 5fa3a73d0769d9426fc647228cddd19fd52a1fc9 /build2/filesystem.cxx | |
parent | 9c8844e80d493eceaa706c1e4cdf983f7e32c59d (diff) |
Use rmsymlink() to portably remove symlinks
Diffstat (limited to 'build2/filesystem.cxx')
-rw-r--r-- | build2/filesystem.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
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<rmfile_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<butl::rmdir_status> rmdir_r (const dir_path& d, bool dir, uint16_t v) { |