From 119f5a88fcd92d3416406fe221cc431b1d3ce7b4 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 15 Nov 2020 07:42:14 -0800 Subject: [PATCH] ircd::fs::path: Translate boost exceptions coming out of tool impls. --- ircd/fs_path.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ircd/fs_path.cc b/ircd/fs_path.cc index b612ca63b..a938a9b67 100644 --- a/ircd/fs_path.cc +++ b/ircd/fs_path.cc @@ -219,62 +219,110 @@ ircd::fs::base::db ircd::string_view ircd::fs::canonical(const mutable_buffer &buf, const string_view &p) +try { return path(buf, canonical(_path(p))); } +catch(const filesystem::filesystem_error &e) +{ + throw error + { + e, "%s", + rsplit(e.what(), ':').second, + }; +} ircd::string_view ircd::fs::canonical(const mutable_buffer &buf, const string_view &root, const string_view &p) +try { return path(buf, canonical(_path(p), _path(root))); } +catch(const filesystem::filesystem_error &e) +{ + throw error + { + e, "%s", + rsplit(e.what(), ':').second, + }; +} ircd::string_view ircd::fs::relative(const mutable_buffer &buf, const string_view &root, const string_view &p) +try { return path(buf, relative(_path(p), _path(root))); } +catch(const filesystem::filesystem_error &e) +{ + throw error{e}; +} ircd::string_view ircd::fs::absolute(const mutable_buffer &buf, const string_view &root, const string_view &p) +try { return path(buf, absolute(_path(p), _path(root))); } +catch(const filesystem::filesystem_error &e) +{ + throw error{e}; +} ircd::string_view ircd::fs::parent(const mutable_buffer &buf, const string_view &p) +try { return path(buf, _path(p).parent_path()); } +catch(const filesystem::filesystem_error &e) +{ + throw error{e}; +} ircd::string_view ircd::fs::filename(const mutable_buffer &buf, const string_view &p) +try { return path(buf, _path(p).filename()); } +catch(const filesystem::filesystem_error &e) +{ + throw error{e}; +} ircd::string_view ircd::fs::extension(const mutable_buffer &buf, const string_view &p) +try { return path(buf, _path(p).extension()); } +catch(const filesystem::filesystem_error &e) +{ + throw error{e}; +} ircd::string_view ircd::fs::extension(const mutable_buffer &buf, const string_view &p, const string_view &replace) +try { return path(buf, _path(p).replace_extension(_path(replace))); } +catch(const filesystem::filesystem_error &e) +{ + throw error{e}; +} bool ircd::fs::is_relative(const string_view &p)