diff --git a/pre/file/string.hpp b/pre/file/string.hpp index c19e65e..7400720 100644 --- a/pre/file/string.hpp +++ b/pre/file/string.hpp @@ -91,4 +91,26 @@ namespace pre::file { } } + inline void from_string(const std::string &path, const std::string &content, std::error_condition &ec,const boost::filesystem::perms& perms) { + from_string(path, content, ec); + if (ec){return;} + boost::system::error_code ec_perms{}; + boost::filesystem::permissions(path, perms, ec_perms); + if(ec_perms){ + ec = std::error_condition{ec_perms.value(), ec_perms.category()}; + } + } + + inline void from_string(const std::string &path, const std::string &content, const boost::filesystem::perms& perms) { + boost::system::error_code ec_perms; + from_string(path, content); + boost::filesystem::permissions(path, perms, ec_perms); + + if (ec_perms) { + throw std::runtime_error("Changing permission of file "s + path + " error "s + ec_perms.message()); + } + } + + + }