aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2018-02-21 22:18:15 -0800
committerRobert Schumacher <roschuma@microsoft.com>2018-02-21 22:18:43 -0800
commit65e241cf8b47a07b85efae85bac14e723864dccb (patch)
tree85c3904f72e4847ff148844eeb41e715d70e5803 /toolsrc/include
parentf6d652c1bf36717d492305defa3dcf94f724b2c9 (diff)
downloadvcpkg-65e241cf8b47a07b85efae85bac14e723864dccb.tar.gz
vcpkg-65e241cf8b47a07b85efae85bac14e723864dccb.zip
[vcpkg] Add non-throwing implementation of write_contents()
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/files.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h
index 9bdc0aa4b..a2bf9c33c 100644
--- a/toolsrc/include/vcpkg/base/files.h
+++ b/toolsrc/include/vcpkg/base/files.h
@@ -34,7 +34,7 @@ namespace vcpkg::Files
virtual std::vector<fs::path> get_files_non_recursive(const fs::path& dir) const = 0;
virtual void write_lines(const fs::path& file_path, const std::vector<std::string>& lines) = 0;
- virtual void write_contents(const fs::path& file_path, const std::string& data) = 0;
+ virtual void write_contents(const fs::path& file_path, const std::string& data, std::error_code& ec) = 0;
virtual void rename(const fs::path& oldpath, const fs::path& newpath) = 0;
virtual bool remove(const fs::path& path) = 0;
virtual bool remove(const fs::path& path, std::error_code& ec) = 0;
@@ -51,6 +51,14 @@ namespace vcpkg::Files
fs::copy_options opts,
std::error_code& ec) = 0;
virtual fs::file_status status(const fs::path& path, std::error_code& ec) const = 0;
+
+ inline void write_contents(const fs::path& file_path, const std::string& data)
+ {
+ std::error_code ec;
+ write_contents(file_path, data, ec);
+ Checks::check_exit(
+ VCPKG_LINE_INFO, ec, "error while writing file: %s: %s", file_path.u8string(), ec.message());
+ }
};
Filesystem& get_real_filesystem();