diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2020-03-25 15:18:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-25 15:18:10 -0700 |
| commit | 42ad12f91d62a6533d909d8b5ee3a46009c2a10a (patch) | |
| tree | db0d7d7e445546afceac0d38fe9cfaf219dff93c /toolsrc/include | |
| parent | 52273558f64dda28bb3c5ada3ee2c33564a5fd31 (diff) | |
| download | vcpkg-42ad12f91d62a6533d909d8b5ee3a46009c2a10a.tar.gz vcpkg-42ad12f91d62a6533d909d8b5ee3a46009c2a10a.zip | |
[vcpkg] Improve common case of ignoring filesystem errors (#10557)
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/files.h | 12 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/ignore_errors.h | 10 |
2 files changed, 19 insertions, 3 deletions
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index bb4a10d49..3b92feabe 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -1,6 +1,7 @@ #pragma once #include <vcpkg/base/expected.h> +#include <vcpkg/base/ignore_errors.h> #if USE_STD_FILESYSTEM #include <filesystem> @@ -126,20 +127,22 @@ namespace vcpkg::Files StringLiteral temp_suffix, std::error_code& ec) = 0; bool remove(const fs::path& path, LineInfo linfo); + bool remove(const fs::path& path, ignore_errors_t); virtual bool remove(const fs::path& path, std::error_code& ec) = 0; virtual void remove_all(const fs::path& path, std::error_code& ec, fs::path& failure_point) = 0; void remove_all(const fs::path& path, LineInfo li); + void remove_all(const fs::path& path, ignore_errors_t); bool exists(const fs::path& path, std::error_code& ec) const; bool exists(LineInfo li, const fs::path& path) const; - // this should probably not exist, but would require a pass through of - // existing code to fix - bool exists(const fs::path& path) const; + bool exists(const fs::path& path, ignore_errors_t = ignore_errors) const; virtual bool is_directory(const fs::path& path) const = 0; virtual bool is_regular_file(const fs::path& path) const = 0; virtual bool is_empty(const fs::path& path) const = 0; virtual bool create_directory(const fs::path& path, std::error_code& ec) = 0; + bool create_directory(const fs::path& path, ignore_errors_t); virtual bool create_directories(const fs::path& path, std::error_code& ec) = 0; + bool create_directories(const fs::path& path, ignore_errors_t); virtual void copy(const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts) = 0; virtual bool copy_file(const fs::path& oldpath, const fs::path& newpath, @@ -149,9 +152,12 @@ namespace vcpkg::Files virtual fs::file_status status(const fs::path& path, std::error_code& ec) const = 0; virtual fs::file_status symlink_status(const fs::path& path, std::error_code& ec) const = 0; fs::file_status status(LineInfo li, const fs::path& p) const noexcept; + fs::file_status status(const fs::path& p, ignore_errors_t) const noexcept; fs::file_status symlink_status(LineInfo li, const fs::path& p) const noexcept; + fs::file_status symlink_status(const fs::path& p, ignore_errors_t) const noexcept; virtual fs::path canonical(const fs::path& path, std::error_code& ec) const = 0; fs::path canonical(LineInfo li, const fs::path& path) const; + fs::path canonical(const fs::path& path, ignore_errors_t) const; virtual std::vector<fs::path> find_from_PATH(const std::string& name) const = 0; }; diff --git a/toolsrc/include/vcpkg/base/ignore_errors.h b/toolsrc/include/vcpkg/base/ignore_errors.h new file mode 100644 index 000000000..44077059a --- /dev/null +++ b/toolsrc/include/vcpkg/base/ignore_errors.h @@ -0,0 +1,10 @@ +#pragma once
+
+namespace vcpkg
+{
+ struct ignore_errors_t
+ {
+ };
+
+ constexpr ignore_errors_t ignore_errors;
+}
|
