From 65e241cf8b47a07b85efae85bac14e723864dccb Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 21 Feb 2018 22:18:15 -0800 Subject: [vcpkg] Add non-throwing implementation of write_contents() --- toolsrc/include/vcpkg/base/files.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'toolsrc/include') 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 get_files_non_recursive(const fs::path& dir) const = 0; virtual void write_lines(const fs::path& file_path, const std::vector& 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(); -- cgit v1.2.3