From 2671c2f83b4499000025d8676a41f7ae1d8dfd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Tue, 7 Apr 2020 10:30:36 +0800 Subject: [PATCH 1/6] use macro protect all throw function directly --- include/ghc/filesystem.hpp | 70 ++++++++++++++++++++++++++++++++++++++ test/CMakeLists.txt | 6 ++++ test/exception.cpp | 5 +++ 3 files changed, 81 insertions(+) create mode 100644 test/exception.cpp diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 1f0fe39..a53a761 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -2033,6 +2033,7 @@ GHC_INLINE path::path(string_type&& source, format fmt) #endif // GHC_EXPAND_IMPL +#ifdef __cpp_exceptions template inline path::path(const Source& source, const std::locale& loc, format fmt) : path(source, fmt) @@ -2052,6 +2053,7 @@ inline path::path(InputIterator first, InputIterator last, const std::locale& lo throw filesystem_error("This implementation only supports UTF-8 locales!", path(_path), detail::make_error_code(detail::portable_error::not_supported)); } } +#endif #ifdef GHC_EXPAND_IMPL @@ -3039,6 +3041,7 @@ GHC_INLINE const char* filesystem_error::what() const noexcept //----------------------------------------------------------------------------- // 30.10.15, filesystem operations +#ifdef __cpp_exceptions GHC_INLINE path absolute(const path& p) { std::error_code ec; @@ -3048,6 +3051,7 @@ GHC_INLINE path absolute(const path& p) } return result; } +#endif GHC_INLINE path absolute(const path& p, std::error_code& ec) { @@ -3098,6 +3102,7 @@ GHC_INLINE path absolute(const path& p, std::error_code& ec) #endif } +#ifdef __cpp_exceptions GHC_INLINE path canonical(const path& p) { std::error_code ec; @@ -3107,6 +3112,7 @@ GHC_INLINE path canonical(const path& p) } return result; } +#endif GHC_INLINE path canonical(const path& p, std::error_code& ec) { @@ -3181,6 +3187,7 @@ GHC_INLINE void copy(const path& from, const path& to, std::error_code& ec) noex copy(from, to, copy_options::none, ec); } +#ifdef __cpp_exceptions GHC_INLINE void copy(const path& from, const path& to, copy_options options) { std::error_code ec; @@ -3189,6 +3196,7 @@ GHC_INLINE void copy(const path& from, const path& to, copy_options options) throw filesystem_error(detail::systemErrorText(ec.value()), from, to, ec); } } +#endif GHC_INLINE void copy(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept { @@ -3276,6 +3284,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, std::error_code& ec) return copy_file(from, to, copy_options::none, ec); } +#ifdef __cpp_exceptions GHC_INLINE bool copy_file(const path& from, const path& to, copy_options option) { std::error_code ec; @@ -3285,6 +3294,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options option) } return result; } +#endif GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept { @@ -3360,6 +3370,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options #endif } +#ifdef __cpp_exceptions GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink) { std::error_code ec; @@ -3368,6 +3379,7 @@ GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symli throw filesystem_error(detail::systemErrorText(ec.value()), existing_symlink, new_symlink, ec); } } +#endif GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink, std::error_code& ec) noexcept { @@ -3383,6 +3395,7 @@ GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symli } } +#ifdef __cpp_exceptions GHC_INLINE bool create_directories(const path& p) { std::error_code ec; @@ -3392,6 +3405,7 @@ GHC_INLINE bool create_directories(const path& p) } return result; } +#endif GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept { @@ -3430,6 +3444,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept return didCreate; } +#ifdef __cpp_exceptions GHC_INLINE bool create_directory(const path& p) { std::error_code ec; @@ -3439,12 +3454,14 @@ GHC_INLINE bool create_directory(const path& p) } return result; } +#endif GHC_INLINE bool create_directory(const path& p, std::error_code& ec) noexcept { return create_directory(p, path(), ec); } +#ifdef __cpp_exceptions GHC_INLINE bool create_directory(const path& p, const path& attributes) { std::error_code ec; @@ -3454,6 +3471,7 @@ GHC_INLINE bool create_directory(const path& p, const path& attributes) } return result; } +#endif GHC_INLINE bool create_directory(const path& p, const path& attributes, std::error_code& ec) noexcept { @@ -3498,6 +3516,7 @@ GHC_INLINE bool create_directory(const path& p, const path& attributes, std::err return true; } +#ifdef __cpp_exceptions GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink) { std::error_code ec; @@ -3506,12 +3525,14 @@ GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink throw filesystem_error(detail::systemErrorText(ec.value()), to, new_symlink, ec); } } +#endif GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept { detail::create_symlink(to, new_symlink, true, ec); } +#ifdef __cpp_exceptions GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link) { std::error_code ec; @@ -3520,12 +3541,14 @@ GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link) throw filesystem_error(detail::systemErrorText(ec.value()), to, new_hard_link, ec); } } +#endif GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link, std::error_code& ec) noexcept { detail::create_hardlink(to, new_hard_link, ec); } +#ifdef __cpp_exceptions GHC_INLINE void create_symlink(const path& to, const path& new_symlink) { std::error_code ec; @@ -3534,12 +3557,14 @@ GHC_INLINE void create_symlink(const path& to, const path& new_symlink) throw filesystem_error(detail::systemErrorText(ec.value()), to, new_symlink, ec); } } +#endif GHC_INLINE void create_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept { detail::create_symlink(to, new_symlink, false, ec); } +#ifdef __cpp_exceptions GHC_INLINE path current_path() { std::error_code ec; @@ -3549,6 +3574,7 @@ GHC_INLINE path current_path() } return result; } +#endif GHC_INLINE path current_path(std::error_code& ec) { @@ -3572,6 +3598,7 @@ GHC_INLINE path current_path(std::error_code& ec) #endif } +#ifdef __cpp_exceptions GHC_INLINE void current_path(const path& p) { std::error_code ec; @@ -3580,6 +3607,7 @@ GHC_INLINE void current_path(const path& p) throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } +#endif GHC_INLINE void current_path(const path& p, std::error_code& ec) noexcept { @@ -3614,6 +3642,7 @@ GHC_INLINE bool exists(const path& p, std::error_code& ec) noexcept return exists(s); } +#ifdef __cpp_exceptions GHC_INLINE bool equivalent(const path& p1, const path& p2) { std::error_code ec; @@ -3623,6 +3652,7 @@ GHC_INLINE bool equivalent(const path& p1, const path& p2) } return result; } +#endif GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) noexcept { @@ -3671,6 +3701,7 @@ GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) #endif } +#ifdef __cpp_exceptions GHC_INLINE uintmax_t file_size(const path& p) { std::error_code ec; @@ -3680,6 +3711,7 @@ GHC_INLINE uintmax_t file_size(const path& p) } return result; } +#endif GHC_INLINE uintmax_t file_size(const path& p, std::error_code& ec) noexcept { @@ -3701,6 +3733,7 @@ GHC_INLINE uintmax_t file_size(const path& p, std::error_code& ec) noexcept #endif } +#ifdef __cpp_exceptions GHC_INLINE uintmax_t hard_link_count(const path& p) { std::error_code ec; @@ -3710,6 +3743,7 @@ GHC_INLINE uintmax_t hard_link_count(const path& p) } return result; } +#endif GHC_INLINE uintmax_t hard_link_count(const path& p, std::error_code& ec) noexcept { @@ -3892,6 +3926,7 @@ GHC_INLINE bool is_symlink(const path& p, std::error_code& ec) noexcept return is_symlink(symlink_status(p, ec)); } +#ifdef __cpp_exceptions GHC_INLINE file_time_type last_write_time(const path& p) { std::error_code ec; @@ -3901,6 +3936,7 @@ GHC_INLINE file_time_type last_write_time(const path& p) } return result; } +#endif GHC_INLINE file_time_type last_write_time(const path& p, std::error_code& ec) noexcept { @@ -3910,6 +3946,7 @@ GHC_INLINE file_time_type last_write_time(const path& p, std::error_code& ec) no return ec ? (file_time_type::min)() : std::chrono::system_clock::from_time_t(result); } +#ifdef __cpp_exceptions GHC_INLINE void last_write_time(const path& p, file_time_type new_time) { std::error_code ec; @@ -3918,6 +3955,7 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time) throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } +#endif GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::error_code& ec) noexcept { @@ -3973,6 +4011,7 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err #endif } +#ifdef __cpp_exceptions GHC_INLINE void permissions(const path& p, perms prms, perm_options opts) { std::error_code ec; @@ -3981,6 +4020,7 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts) throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } +#endif GHC_INLINE void permissions(const path& p, perms prms, std::error_code& ec) noexcept { @@ -4048,6 +4088,7 @@ GHC_INLINE path proximate(const path& p, const path& base, std::error_code& ec) return weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec)); } +#ifdef __cpp_exceptions GHC_INLINE path read_symlink(const path& p) { std::error_code ec; @@ -4057,6 +4098,7 @@ GHC_INLINE path read_symlink(const path& p) } return result; } +#endif GHC_INLINE path read_symlink(const path& p, std::error_code& ec) { @@ -4084,6 +4126,7 @@ GHC_INLINE path relative(const path& p, const path& base, std::error_code& ec) return weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool remove(const path& p) { std::error_code ec; @@ -4093,6 +4136,7 @@ GHC_INLINE bool remove(const path& p) } return result; } +#endif GHC_INLINE bool remove(const path& p, std::error_code& ec) noexcept { @@ -4131,6 +4175,7 @@ GHC_INLINE bool remove(const path& p, std::error_code& ec) noexcept return ec ? false : true; } +#ifdef __cpp_exceptions GHC_INLINE uintmax_t remove_all(const path& p) { std::error_code ec; @@ -4140,6 +4185,7 @@ GHC_INLINE uintmax_t remove_all(const path& p) } return result; } +#endif GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept { @@ -4182,6 +4228,7 @@ GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept return count; } +#ifdef __cpp_exceptions GHC_INLINE void rename(const path& from, const path& to) { std::error_code ec; @@ -4190,6 +4237,7 @@ GHC_INLINE void rename(const path& from, const path& to) throw filesystem_error(detail::systemErrorText(ec.value()), from, to, ec); } } +#endif GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) noexcept { @@ -4209,6 +4257,7 @@ GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) no #endif } +#ifdef __cpp_exceptions GHC_INLINE void resize_file(const path& p, uintmax_t size) { std::error_code ec; @@ -4217,6 +4266,7 @@ GHC_INLINE void resize_file(const path& p, uintmax_t size) throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } +#endif GHC_INLINE void resize_file(const path& p, uintmax_t size, std::error_code& ec) noexcept { @@ -4246,6 +4296,7 @@ GHC_INLINE void resize_file(const path& p, uintmax_t size, std::error_code& ec) #endif } +#ifdef __cpp_exceptions GHC_INLINE space_info space(const path& p) { std::error_code ec; @@ -4255,6 +4306,7 @@ GHC_INLINE space_info space(const path& p) } return result; } +#endif GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept { @@ -4282,6 +4334,7 @@ GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept #endif } +#ifdef __cpp_exceptions GHC_INLINE file_status status(const path& p) { std::error_code ec; @@ -4291,6 +4344,7 @@ GHC_INLINE file_status status(const path& p) } return result; } +#endif GHC_INLINE file_status status(const path& p, std::error_code& ec) noexcept { @@ -4302,6 +4356,7 @@ GHC_INLINE bool status_known(file_status s) noexcept return s.type() != file_type::none; } +#ifdef __cpp_exceptions GHC_INLINE file_status symlink_status(const path& p) { std::error_code ec; @@ -4311,12 +4366,14 @@ GHC_INLINE file_status symlink_status(const path& p) } return result; } +#endif GHC_INLINE file_status symlink_status(const path& p, std::error_code& ec) noexcept { return detail::symlink_status_ex(p, ec); } +#ifdef __cpp_exceptions GHC_INLINE path temp_directory_path() { std::error_code ec; @@ -4326,6 +4383,7 @@ GHC_INLINE path temp_directory_path() } return result; } +#endif GHC_INLINE path temp_directory_path(std::error_code& ec) noexcept { @@ -4351,6 +4409,7 @@ GHC_INLINE path temp_directory_path(std::error_code& ec) noexcept #endif } +#ifdef __cpp_exceptions GHC_INLINE path weakly_canonical(const path& p) { std::error_code ec; @@ -4360,6 +4419,7 @@ GHC_INLINE path weakly_canonical(const path& p) } return result; } +#endif GHC_INLINE path weakly_canonical(const path& p, std::error_code& ec) noexcept { @@ -4524,6 +4584,7 @@ GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p, std refresh(ec); } +#ifdef __cpp_exceptions GHC_INLINE void directory_entry::refresh() { std::error_code ec; @@ -4532,6 +4593,7 @@ GHC_INLINE void directory_entry::refresh() throw filesystem_error(detail::systemErrorText(ec.value()), _path, ec); } } +#endif GHC_INLINE void directory_entry::refresh(std::error_code& ec) noexcept { @@ -4933,6 +4995,7 @@ GHC_INLINE directory_iterator::directory_iterator() noexcept { } +#ifdef __cpp_exceptions GHC_INLINE directory_iterator::directory_iterator(const path& p) : _impl(new impl(p, directory_options::none)) { @@ -4949,6 +5012,7 @@ GHC_INLINE directory_iterator::directory_iterator(const path& p, directory_optio throw filesystem_error(detail::systemErrorText(_impl->_ec.value()), p, _impl->_ec); } } +#endif GHC_INLINE directory_iterator::directory_iterator(const path& p, std::error_code& ec) noexcept : _impl(new impl(p, directory_options::none)) @@ -5000,6 +5064,7 @@ GHC_INLINE const directory_entry* directory_iterator::operator->() const return &_impl->_dir_entry; } +#ifdef __cpp_exceptions GHC_INLINE directory_iterator& directory_iterator::operator++() { std::error_code ec; @@ -5009,6 +5074,7 @@ GHC_INLINE directory_iterator& directory_iterator::operator++() } return *this; } +#endif GHC_INLINE directory_iterator& directory_iterator::increment(std::error_code& ec) noexcept { @@ -5122,6 +5188,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator= return *this; } +#ifdef __cpp_exceptions GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator++() { std::error_code ec; @@ -5131,6 +5198,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator+ } return *this; } +#endif GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment(std::error_code& ec) noexcept { @@ -5153,6 +5221,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment return *this; } +#ifdef __cpp_exceptions GHC_INLINE void recursive_directory_iterator::pop() { std::error_code ec; @@ -5161,6 +5230,7 @@ GHC_INLINE void recursive_directory_iterator::pop() throw filesystem_error(detail::systemErrorText(ec.value()), _impl->_dir_iter_stack.empty() ? path() : _impl->_dir_iter_stack.top()->path(), ec); } } +#endif GHC_INLINE void recursive_directory_iterator::pop(std::error_code& ec) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 71255a4..3c5a9e7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -52,3 +52,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) target_compile_definitions(fwd_impl_test PRIVATE _CRT_SECURE_NO_WARNINGS) endif() add_test(fwd_impl_test fwd_impl_test) + +add_executable(exception exception.cpp) +if(NOT MSVC) + target_compile_options(exception PRIVATE -fno-exceptions) + target_include_directories(exception PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) +endif() diff --git a/test/exception.cpp b/test/exception.cpp new file mode 100644 index 0000000..8d8b745 --- /dev/null +++ b/test/exception.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + return 0; +} From a0ef036074049d99938598d3b29f155d92517e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Tue, 7 Apr 2020 11:40:42 +0800 Subject: [PATCH 2/6] use marcro protect all code with exception --- include/ghc/filesystem.hpp | 216 ++++++++++++++++++++++++++++++++++++- 1 file changed, 214 insertions(+), 2 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index a53a761..ce816c7 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -278,10 +278,12 @@ class GHC_FS_API_CLASS path path(const Source& source, format fmt = auto_format); template path(InputIterator first, InputIterator last, format fmt = auto_format); +#ifdef __cpp_exceptions template > path(const Source& source, const std::locale& loc, format fmt = auto_format); template path(InputIterator first, InputIterator last, const std::locale& loc, format fmt = auto_format); +#endif ~path(); // 30.10.8.4.2 assignments @@ -617,7 +619,9 @@ class GHC_FS_API_CLASS directory_entry directory_entry() noexcept = default; directory_entry(const directory_entry&) = default; directory_entry(directory_entry&&) noexcept = default; +#ifdef __cpp_exceptions explicit directory_entry(const path& p); +#endif directory_entry(const path& p, std::error_code& ec); ~directory_entry(); @@ -626,45 +630,79 @@ class GHC_FS_API_CLASS directory_entry directory_entry& operator=(directory_entry&&) noexcept = default; // 30.10.12.2 modifiers +#ifdef __cpp_exceptions void assign(const path& p); +#endif void assign(const path& p, std::error_code& ec); +#ifdef __cpp_exceptions void replace_filename(const path& p); +#endif void replace_filename(const path& p, std::error_code& ec); +#ifdef __cpp_exceptions void refresh(); +#endif void refresh(std::error_code& ec) noexcept; // 30.10.12.3 observers const filesystem::path& path() const noexcept; operator const filesystem::path&() const noexcept; +#ifdef __cpp_exceptions bool exists() const; +#endif bool exists(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions bool is_block_file() const; +#endif bool is_block_file(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions bool is_character_file() const; +#endif bool is_character_file(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions bool is_directory() const; +#endif bool is_directory(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions bool is_fifo() const; +#endif bool is_fifo(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions bool is_other() const; +#endif bool is_other(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions bool is_regular_file() const; +#endif bool is_regular_file(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions bool is_socket() const; +#endif bool is_socket(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions bool is_symlink() const; +#endif bool is_symlink(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions uintmax_t file_size() const; +#endif uintmax_t file_size(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions uintmax_t hard_link_count() const; +#endif uintmax_t hard_link_count(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions file_time_type last_write_time() const; +#endif file_time_type last_write_time(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions file_status status() const; +#endif file_status status(std::error_code& ec) const noexcept; +#ifdef __cpp_exceptions file_status symlink_status() const; +#endif file_status symlink_status(std::error_code& ec) const noexcept; bool operator<(const directory_entry& rhs) const noexcept; bool operator==(const directory_entry& rhs) const noexcept; @@ -712,8 +750,10 @@ class GHC_FS_API_CLASS directory_iterator // 30.10.13.1 member functions directory_iterator() noexcept; +#ifdef __cpp_exceptions explicit directory_iterator(const path& p); directory_iterator(const path& p, directory_options options); +#endif directory_iterator(const path& p, std::error_code& ec) noexcept; directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept; directory_iterator(const directory_iterator& rhs); @@ -723,16 +763,20 @@ class GHC_FS_API_CLASS directory_iterator directory_iterator& operator=(directory_iterator&& rhs) noexcept; const directory_entry& operator*() const; const directory_entry* operator->() const; +#ifdef __cpp_exceptions directory_iterator& operator++(); +#endif directory_iterator& increment(std::error_code& ec) noexcept; // other members as required by 27.2.3, input iterators +#ifdef __cpp_exceptions proxy operator++(int) { proxy p{**this}; ++*this; return p; } +#endif bool operator==(const directory_iterator& rhs) const; bool operator!=(const directory_iterator& rhs) const; @@ -758,8 +802,10 @@ class GHC_FS_API_CLASS recursive_directory_iterator // 30.10.14.1 constructors and destructor recursive_directory_iterator() noexcept; +#ifdef __cpp_exceptions explicit recursive_directory_iterator(const path& p); recursive_directory_iterator(const path& p, directory_options options); +#endif recursive_directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept; recursive_directory_iterator(const path& p, std::error_code& ec) noexcept; recursive_directory_iterator(const recursive_directory_iterator& rhs); @@ -777,20 +823,26 @@ class GHC_FS_API_CLASS recursive_directory_iterator // 30.10.14.1 modifiers recursive_directory_iterator& recursive_directory_iterator& operator=(const recursive_directory_iterator& rhs); recursive_directory_iterator& operator=(recursive_directory_iterator&& rhs) noexcept; +#ifdef __cpp_exceptions recursive_directory_iterator& operator++(); +#endif recursive_directory_iterator& increment(std::error_code& ec) noexcept; +#ifdef __cpp_exceptions void pop(); +#endif void pop(std::error_code& ec); void disable_recursion_pending(); // other members as required by 27.2.3, input iterators +#ifdef __cpp_exceptions directory_iterator::proxy operator++(int) { directory_iterator::proxy proxy{**this}; ++*this; return proxy; } +#endif bool operator==(const recursive_directory_iterator& rhs) const; bool operator!=(const recursive_directory_iterator& rhs) const; @@ -814,135 +866,221 @@ GHC_FS_API recursive_directory_iterator begin(recursive_directory_iterator iter) GHC_FS_API recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; // 30.10.15 filesystem operations +#ifdef __cpp_exceptions GHC_FS_API path absolute(const path& p); +#endif GHC_FS_API path absolute(const path& p, std::error_code& ec); +#ifdef __cpp_exceptions GHC_FS_API path canonical(const path& p); +#endif GHC_FS_API path canonical(const path& p, std::error_code& ec); +#ifdef __cpp_exceptions GHC_FS_API void copy(const path& from, const path& to); +#endif GHC_FS_API void copy(const path& from, const path& to, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void copy(const path& from, const path& to, copy_options options); +#endif GHC_FS_API void copy(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool copy_file(const path& from, const path& to); +#endif GHC_FS_API bool copy_file(const path& from, const path& to, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option); +#endif GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink); +#endif GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool create_directories(const path& p); +#endif GHC_FS_API bool create_directories(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool create_directory(const path& p); +#endif GHC_FS_API bool create_directory(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool create_directory(const path& p, const path& attributes); +#endif GHC_FS_API bool create_directory(const path& p, const path& attributes, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink); +#endif GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link); +#endif GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void create_symlink(const path& to, const path& new_symlink); +#endif GHC_FS_API void create_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API path current_path(); +#endif GHC_FS_API path current_path(std::error_code& ec); +#ifdef __cpp_exceptions GHC_FS_API void current_path(const path& p); +#endif GHC_FS_API void current_path(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool exists(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool exists(const path& p); +#endif GHC_FS_API bool exists(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool equivalent(const path& p1, const path& p2); +#endif GHC_FS_API bool equivalent(const path& p1, const path& p2, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API uintmax_t file_size(const path& p); +#endif GHC_FS_API uintmax_t file_size(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API uintmax_t hard_link_count(const path& p); +#endif GHC_FS_API uintmax_t hard_link_count(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_block_file(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_block_file(const path& p); +#endif GHC_FS_API bool is_block_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_character_file(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_character_file(const path& p); +#endif GHC_FS_API bool is_character_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_directory(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_directory(const path& p); +#endif GHC_FS_API bool is_directory(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_empty(const path& p); +#endif GHC_FS_API bool is_empty(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_fifo(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_fifo(const path& p); +#endif GHC_FS_API bool is_fifo(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_other(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_other(const path& p); +#endif GHC_FS_API bool is_other(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_regular_file(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_regular_file(const path& p); +#endif GHC_FS_API bool is_regular_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_socket(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_socket(const path& p); +#endif GHC_FS_API bool is_socket(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_symlink(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API bool is_symlink(const path& p); +#endif GHC_FS_API bool is_symlink(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API file_time_type last_write_time(const path& p); +#endif GHC_FS_API file_time_type last_write_time(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void last_write_time(const path& p, file_time_type new_time); +#endif GHC_FS_API void last_write_time(const path& p, file_time_type new_time, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void permissions(const path& p, perms prms, perm_options opts = perm_options::replace); +#endif GHC_FS_API void permissions(const path& p, perms prms, std::error_code& ec) noexcept; GHC_FS_API void permissions(const path& p, perms prms, perm_options opts, std::error_code& ec); +#ifdef __cpp_exceptions GHC_FS_API path proximate(const path& p, std::error_code& ec); GHC_FS_API path proximate(const path& p, const path& base = current_path()); +#endif GHC_FS_API path proximate(const path& p, const path& base, std::error_code& ec); +#ifdef __cpp_exceptions GHC_FS_API path read_symlink(const path& p); +#endif GHC_FS_API path read_symlink(const path& p, std::error_code& ec); GHC_FS_API path relative(const path& p, std::error_code& ec); +#ifdef __cpp_exceptions GHC_FS_API path relative(const path& p, const path& base = current_path()); +#endif GHC_FS_API path relative(const path& p, const path& base, std::error_code& ec); +#ifdef __cpp_exceptions GHC_FS_API bool remove(const path& p); +#endif GHC_FS_API bool remove(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API uintmax_t remove_all(const path& p); +#endif GHC_FS_API uintmax_t remove_all(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void rename(const path& from, const path& to); +#endif GHC_FS_API void rename(const path& from, const path& to, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API void resize_file(const path& p, uintmax_t size); +#endif GHC_FS_API void resize_file(const path& p, uintmax_t size, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API space_info space(const path& p); +#endif GHC_FS_API space_info space(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API file_status status(const path& p); +#endif GHC_FS_API file_status status(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool status_known(file_status s) noexcept; +#ifdef __cpp_exceptions GHC_FS_API file_status symlink_status(const path& p); +#endif GHC_FS_API file_status symlink_status(const path& p, std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API path temp_directory_path(); +#endif GHC_FS_API path temp_directory_path(std::error_code& ec) noexcept; +#ifdef __cpp_exceptions GHC_FS_API path weakly_canonical(const path& p); +#endif GHC_FS_API path weakly_canonical(const path& p, std::error_code& ec) noexcept; // Non-C++17 add-on std::fstream wrappers with path @@ -3177,10 +3315,12 @@ GHC_INLINE path canonical(const path& p, std::error_code& ec) return result; } +#ifdef __cpp_exceptions GHC_INLINE void copy(const path& from, const path& to) { copy(from, to, copy_options::none); } +#endif GHC_INLINE void copy(const path& from, const path& to, std::error_code& ec) noexcept { @@ -3274,10 +3414,12 @@ GHC_INLINE void copy(const path& from, const path& to, copy_options options, std return; } +#ifdef __cpp_exceptions GHC_INLINE bool copy_file(const path& from, const path& to) { return copy_file(from, to, copy_options::none); } +#endif GHC_INLINE bool copy_file(const path& from, const path& to, std::error_code& ec) noexcept { @@ -3628,10 +3770,12 @@ GHC_INLINE bool exists(file_status s) noexcept return status_known(s) && s.type() != file_type::not_found; } +#ifdef __cpp_exceptions GHC_INLINE bool exists(const path& p) { return exists(status(p)); } +#endif GHC_INLINE bool exists(const path& p, std::error_code& ec) noexcept { @@ -3779,10 +3923,12 @@ GHC_INLINE bool is_block_file(file_status s) noexcept return s.type() == file_type::block; } +#ifdef __cpp_exceptions GHC_INLINE bool is_block_file(const path& p) { return is_block_file(status(p)); } +#endif GHC_INLINE bool is_block_file(const path& p, std::error_code& ec) noexcept { @@ -3794,10 +3940,12 @@ GHC_INLINE bool is_character_file(file_status s) noexcept return s.type() == file_type::character; } +#ifdef __cpp_exceptions GHC_INLINE bool is_character_file(const path& p) { return is_character_file(status(p)); } +#endif GHC_INLINE bool is_character_file(const path& p, std::error_code& ec) noexcept { @@ -3809,16 +3957,19 @@ GHC_INLINE bool is_directory(file_status s) noexcept return s.type() == file_type::directory; } +#ifdef __cpp_exceptions GHC_INLINE bool is_directory(const path& p) { return is_directory(status(p)); } +#endif GHC_INLINE bool is_directory(const path& p, std::error_code& ec) noexcept { return is_directory(status(p, ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool is_empty(const path& p) { if (is_directory(p)) { @@ -3828,6 +3979,7 @@ GHC_INLINE bool is_empty(const path& p) return file_size(p) == 0; } } +#endif GHC_INLINE bool is_empty(const path& p, std::error_code& ec) noexcept { @@ -3856,10 +4008,12 @@ GHC_INLINE bool is_fifo(file_status s) noexcept return s.type() == file_type::fifo; } +#ifdef __cpp_exceptions GHC_INLINE bool is_fifo(const path& p) { return is_fifo(status(p)); } +#endif GHC_INLINE bool is_fifo(const path& p, std::error_code& ec) noexcept { @@ -3871,10 +4025,12 @@ GHC_INLINE bool is_other(file_status s) noexcept return exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s); } +#ifdef __cpp_exceptions GHC_INLINE bool is_other(const path& p) { return is_other(status(p)); } +#endif GHC_INLINE bool is_other(const path& p, std::error_code& ec) noexcept { @@ -3886,10 +4042,12 @@ GHC_INLINE bool is_regular_file(file_status s) noexcept return s.type() == file_type::regular; } +#ifdef __cpp_exceptions GHC_INLINE bool is_regular_file(const path& p) { return is_regular_file(status(p)); } +#endif GHC_INLINE bool is_regular_file(const path& p, std::error_code& ec) noexcept { @@ -3901,10 +4059,12 @@ GHC_INLINE bool is_socket(file_status s) noexcept return s.type() == file_type::socket; } +#ifdef __cpp_exceptions GHC_INLINE bool is_socket(const path& p) { return is_socket(status(p)); } +#endif GHC_INLINE bool is_socket(const path& p, std::error_code& ec) noexcept { @@ -3916,10 +4076,12 @@ GHC_INLINE bool is_symlink(file_status s) noexcept return s.type() == file_type::symlink; } +#ifdef __cpp_exceptions GHC_INLINE bool is_symlink(const path& p) { return is_symlink(symlink_status(p)); } +#endif GHC_INLINE bool is_symlink(const path& p, std::error_code& ec) noexcept { @@ -4073,15 +4235,19 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::e #endif } +#ifdef __cpp_exceptions GHC_INLINE path proximate(const path& p, std::error_code& ec) { return proximate(p, current_path(), ec); } +#endif +#ifdef __cpp_exceptions GHC_INLINE path proximate(const path& p, const path& base) { return weakly_canonical(p).lexically_proximate(weakly_canonical(base)); } +#endif GHC_INLINE path proximate(const path& p, const path& base, std::error_code& ec) { @@ -4116,10 +4282,12 @@ GHC_INLINE path relative(const path& p, std::error_code& ec) return relative(p, current_path(ec), ec); } +#ifdef __cpp_exceptions GHC_INLINE path relative(const path& p, const path& base) { return weakly_canonical(p).lexically_relative(weakly_canonical(base)); } +#endif GHC_INLINE path relative(const path& p, const path& base, std::error_code& ec) { @@ -4202,7 +4370,11 @@ GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept if (ec) { break; } - if (!iter->is_symlink() && iter->is_directory()) { + bool is_symlink_result = iter->is_symlink(ec); + if (ec) return static_cast(-1); + bool is_directory_result = iter->is_directory(ec); + if (ec) return static_cast(-1); + if (!is_symlink_result && is_directory_result) { count += remove_all(iter->path(), ec); if (ec) { return static_cast(-1); @@ -4531,6 +4703,7 @@ GHC_INLINE perms file_status::permissions() const noexcept // directory_entry::directory_entry() noexcept = default; // directory_entry::directory_entry(const directory_entry&) = default; // directory_entry::directory_entry(directory_entry&&) noexcept = default; +#ifdef __cpp_exceptions GHC_INLINE directory_entry::directory_entry(const filesystem::path& p) : _path(p) , _file_size(0) @@ -4541,6 +4714,7 @@ GHC_INLINE directory_entry::directory_entry(const filesystem::path& p) { refresh(); } +#endif GHC_INLINE directory_entry::directory_entry(const filesystem::path& p, std::error_code& ec) : _path(p) @@ -4560,11 +4734,13 @@ GHC_INLINE directory_entry::~directory_entry() {} // directory_entry& directory_entry::operator=(directory_entry&&) noexcept = default; // 30.10.12.2 directory_entry modifiers +#ifdef __cpp_exceptions GHC_INLINE void directory_entry::assign(const filesystem::path& p) { _path = p; refresh(); } +#endif GHC_INLINE void directory_entry::assign(const filesystem::path& p, std::error_code& ec) { @@ -4572,11 +4748,13 @@ GHC_INLINE void directory_entry::assign(const filesystem::path& p, std::error_co refresh(ec); } +#ifdef __cpp_exceptions GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p) { _path.replace_filename(p); refresh(); } +#endif GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p, std::error_code& ec) { @@ -4615,95 +4793,114 @@ GHC_INLINE directory_entry::operator const filesystem::path&() const noexcept return _path; } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::exists() const { return filesystem::exists(status()); } +#endif GHC_INLINE bool directory_entry::exists(std::error_code& ec) const noexcept { return filesystem::exists(status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::is_block_file() const { return filesystem::is_block_file(status()); } +#endif GHC_INLINE bool directory_entry::is_block_file(std::error_code& ec) const noexcept { return filesystem::is_block_file(status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::is_character_file() const { return filesystem::is_character_file(status()); } +#endif GHC_INLINE bool directory_entry::is_character_file(std::error_code& ec) const noexcept { return filesystem::is_character_file(status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::is_directory() const { return filesystem::is_directory(status()); } +#endif GHC_INLINE bool directory_entry::is_directory(std::error_code& ec) const noexcept { return filesystem::is_directory(status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::is_fifo() const { return filesystem::is_fifo(status()); } +#endif GHC_INLINE bool directory_entry::is_fifo(std::error_code& ec) const noexcept { return filesystem::is_fifo(status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::is_other() const { return filesystem::is_other(status()); } +#endif GHC_INLINE bool directory_entry::is_other(std::error_code& ec) const noexcept { return filesystem::is_other(status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::is_regular_file() const { return filesystem::is_regular_file(status()); } +#endif GHC_INLINE bool directory_entry::is_regular_file(std::error_code& ec) const noexcept { return filesystem::is_regular_file(status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::is_socket() const { return filesystem::is_socket(status()); } +#endif GHC_INLINE bool directory_entry::is_socket(std::error_code& ec) const noexcept { return filesystem::is_socket(status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE bool directory_entry::is_symlink() const { return filesystem::is_symlink(symlink_status()); } +#endif GHC_INLINE bool directory_entry::is_symlink(std::error_code& ec) const noexcept { return filesystem::is_symlink(symlink_status(ec)); } +#ifdef __cpp_exceptions GHC_INLINE uintmax_t directory_entry::file_size() const { if (_status.type() != file_type::none) { @@ -4711,6 +4908,7 @@ GHC_INLINE uintmax_t directory_entry::file_size() const } return filesystem::file_size(path()); } +#endif GHC_INLINE uintmax_t directory_entry::file_size(std::error_code& ec) const noexcept { @@ -4721,6 +4919,7 @@ GHC_INLINE uintmax_t directory_entry::file_size(std::error_code& ec) const noexc return filesystem::file_size(path(), ec); } +#ifdef __cpp_exceptions GHC_INLINE uintmax_t directory_entry::hard_link_count() const { #ifndef GHC_OS_WINDOWS @@ -4730,6 +4929,7 @@ GHC_INLINE uintmax_t directory_entry::hard_link_count() const #endif return filesystem::hard_link_count(path()); } +#endif GHC_INLINE uintmax_t directory_entry::hard_link_count(std::error_code& ec) const noexcept { @@ -4742,6 +4942,7 @@ GHC_INLINE uintmax_t directory_entry::hard_link_count(std::error_code& ec) const return filesystem::hard_link_count(path(), ec); } +#ifdef __cpp_exceptions GHC_INLINE file_time_type directory_entry::last_write_time() const { if (_status.type() != file_type::none) { @@ -4749,6 +4950,7 @@ GHC_INLINE file_time_type directory_entry::last_write_time() const } return filesystem::last_write_time(path()); } +#endif GHC_INLINE file_time_type directory_entry::last_write_time(std::error_code& ec) const noexcept { @@ -4759,6 +4961,7 @@ GHC_INLINE file_time_type directory_entry::last_write_time(std::error_code& ec) return filesystem::last_write_time(path(), ec); } +#ifdef __cpp_exceptions GHC_INLINE file_status directory_entry::status() const { if (_status.type() != file_type::none) { @@ -4766,6 +4969,7 @@ GHC_INLINE file_status directory_entry::status() const } return filesystem::status(path()); } +#endif GHC_INLINE file_status directory_entry::status(std::error_code& ec) const noexcept { @@ -4776,6 +4980,7 @@ GHC_INLINE file_status directory_entry::status(std::error_code& ec) const noexce return filesystem::status(path(), ec); } +#ifdef __cpp_exceptions GHC_INLINE file_status directory_entry::symlink_status() const { if (_symlink_status.type() != file_type::none) { @@ -4783,6 +4988,7 @@ GHC_INLINE file_status directory_entry::symlink_status() const } return filesystem::symlink_status(path()); } +#endif GHC_INLINE file_status directory_entry::symlink_status(std::error_code& ec) const noexcept { @@ -5113,6 +5319,7 @@ GHC_INLINE recursive_directory_iterator::recursive_directory_iterator() noexcept _impl->_dir_iter_stack.push(directory_iterator()); } +#ifdef __cpp_exceptions GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p) : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { @@ -5124,6 +5331,7 @@ GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path { _impl->_dir_iter_stack.push(directory_iterator(p, options)); } +#endif GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept : _impl(new recursive_directory_iterator_impl(options, true)) @@ -5202,7 +5410,11 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator+ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment(std::error_code& ec) noexcept { - if (recursion_pending() && is_directory((*this)->status()) && (!is_symlink((*this)->symlink_status()) || (options() & directory_options::follow_directory_symlink) != directory_options::none)) { + auto status = (*this)->status(ec); + if (ec) return *this; + auto symlink_status = (*this)->symlink_status(ec); + if (ec) return *this; + if (recursion_pending() && is_directory(status) && (!is_symlink(symlink_status) || (options() & directory_options::follow_directory_symlink) != directory_options::none)) { _impl->_dir_iter_stack.push(directory_iterator((*this)->path(), _impl->_options, ec)); } else { From bab6409d4e04674ab82266969c193e7c7d7a53c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Tue, 7 Apr 2020 12:20:14 +0800 Subject: [PATCH 3/6] Fix MSVC compatibility --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3c5a9e7..9ad6842 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -56,5 +56,5 @@ add_test(fwd_impl_test fwd_impl_test) add_executable(exception exception.cpp) if(NOT MSVC) target_compile_options(exception PRIVATE -fno-exceptions) - target_include_directories(exception PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) endif() +target_include_directories(exception PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) From 4fe99da720c9761ea32dc95468985a56954b0d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Tue, 7 Apr 2020 14:07:47 +0800 Subject: [PATCH 4/6] Fix VS2015 compatibility --- include/ghc/filesystem.hpp | 274 ++++++++++++++++++------------------- 1 file changed, 137 insertions(+), 137 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index ce816c7..9ff04a6 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -278,7 +278,7 @@ class GHC_FS_API_CLASS path path(const Source& source, format fmt = auto_format); template path(InputIterator first, InputIterator last, format fmt = auto_format); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) template > path(const Source& source, const std::locale& loc, format fmt = auto_format); template @@ -619,7 +619,7 @@ class GHC_FS_API_CLASS directory_entry directory_entry() noexcept = default; directory_entry(const directory_entry&) = default; directory_entry(directory_entry&&) noexcept = default; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) explicit directory_entry(const path& p); #endif directory_entry(const path& p, std::error_code& ec); @@ -630,15 +630,15 @@ class GHC_FS_API_CLASS directory_entry directory_entry& operator=(directory_entry&&) noexcept = default; // 30.10.12.2 modifiers -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) void assign(const path& p); #endif void assign(const path& p, std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) void replace_filename(const path& p); #endif void replace_filename(const path& p, std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) void refresh(); #endif void refresh(std::error_code& ec) noexcept; @@ -646,61 +646,61 @@ class GHC_FS_API_CLASS directory_entry // 30.10.12.3 observers const filesystem::path& path() const noexcept; operator const filesystem::path&() const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool exists() const; #endif bool exists(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool is_block_file() const; #endif bool is_block_file(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool is_character_file() const; #endif bool is_character_file(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool is_directory() const; #endif bool is_directory(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool is_fifo() const; #endif bool is_fifo(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool is_other() const; #endif bool is_other(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool is_regular_file() const; #endif bool is_regular_file(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool is_socket() const; #endif bool is_socket(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) bool is_symlink() const; #endif bool is_symlink(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) uintmax_t file_size() const; #endif uintmax_t file_size(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) uintmax_t hard_link_count() const; #endif uintmax_t hard_link_count(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) file_time_type last_write_time() const; #endif file_time_type last_write_time(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) file_status status() const; #endif file_status status(std::error_code& ec) const noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) file_status symlink_status() const; #endif file_status symlink_status(std::error_code& ec) const noexcept; @@ -750,7 +750,7 @@ class GHC_FS_API_CLASS directory_iterator // 30.10.13.1 member functions directory_iterator() noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) explicit directory_iterator(const path& p); directory_iterator(const path& p, directory_options options); #endif @@ -763,13 +763,13 @@ class GHC_FS_API_CLASS directory_iterator directory_iterator& operator=(directory_iterator&& rhs) noexcept; const directory_entry& operator*() const; const directory_entry* operator->() const; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) directory_iterator& operator++(); #endif directory_iterator& increment(std::error_code& ec) noexcept; // other members as required by 27.2.3, input iterators -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) proxy operator++(int) { proxy p{**this}; @@ -802,7 +802,7 @@ class GHC_FS_API_CLASS recursive_directory_iterator // 30.10.14.1 constructors and destructor recursive_directory_iterator() noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) explicit recursive_directory_iterator(const path& p); recursive_directory_iterator(const path& p, directory_options options); #endif @@ -823,19 +823,19 @@ class GHC_FS_API_CLASS recursive_directory_iterator // 30.10.14.1 modifiers recursive_directory_iterator& recursive_directory_iterator& operator=(const recursive_directory_iterator& rhs); recursive_directory_iterator& operator=(recursive_directory_iterator&& rhs) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) recursive_directory_iterator& operator++(); #endif recursive_directory_iterator& increment(std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) void pop(); #endif void pop(std::error_code& ec); void disable_recursion_pending(); // other members as required by 27.2.3, input iterators -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) directory_iterator::proxy operator++(int) { directory_iterator::proxy proxy{**this}; @@ -866,219 +866,219 @@ GHC_FS_API recursive_directory_iterator begin(recursive_directory_iterator iter) GHC_FS_API recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; // 30.10.15 filesystem operations -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API path absolute(const path& p); #endif GHC_FS_API path absolute(const path& p, std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API path canonical(const path& p); #endif GHC_FS_API path canonical(const path& p, std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void copy(const path& from, const path& to); #endif GHC_FS_API void copy(const path& from, const path& to, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void copy(const path& from, const path& to, copy_options options); #endif GHC_FS_API void copy(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool copy_file(const path& from, const path& to); #endif GHC_FS_API bool copy_file(const path& from, const path& to, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option); #endif GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink); #endif GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool create_directories(const path& p); #endif GHC_FS_API bool create_directories(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool create_directory(const path& p); #endif GHC_FS_API bool create_directory(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool create_directory(const path& p, const path& attributes); #endif GHC_FS_API bool create_directory(const path& p, const path& attributes, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink); #endif GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link); #endif GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void create_symlink(const path& to, const path& new_symlink); #endif GHC_FS_API void create_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API path current_path(); #endif GHC_FS_API path current_path(std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void current_path(const path& p); #endif GHC_FS_API void current_path(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool exists(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool exists(const path& p); #endif GHC_FS_API bool exists(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool equivalent(const path& p1, const path& p2); #endif GHC_FS_API bool equivalent(const path& p1, const path& p2, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API uintmax_t file_size(const path& p); #endif GHC_FS_API uintmax_t file_size(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API uintmax_t hard_link_count(const path& p); #endif GHC_FS_API uintmax_t hard_link_count(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_block_file(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_block_file(const path& p); #endif GHC_FS_API bool is_block_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_character_file(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_character_file(const path& p); #endif GHC_FS_API bool is_character_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_directory(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_directory(const path& p); #endif GHC_FS_API bool is_directory(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_empty(const path& p); #endif GHC_FS_API bool is_empty(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_fifo(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_fifo(const path& p); #endif GHC_FS_API bool is_fifo(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_other(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_other(const path& p); #endif GHC_FS_API bool is_other(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_regular_file(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_regular_file(const path& p); #endif GHC_FS_API bool is_regular_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_socket(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_socket(const path& p); #endif GHC_FS_API bool is_socket(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_symlink(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool is_symlink(const path& p); #endif GHC_FS_API bool is_symlink(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API file_time_type last_write_time(const path& p); #endif GHC_FS_API file_time_type last_write_time(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void last_write_time(const path& p, file_time_type new_time); #endif GHC_FS_API void last_write_time(const path& p, file_time_type new_time, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void permissions(const path& p, perms prms, perm_options opts = perm_options::replace); #endif GHC_FS_API void permissions(const path& p, perms prms, std::error_code& ec) noexcept; GHC_FS_API void permissions(const path& p, perms prms, perm_options opts, std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API path proximate(const path& p, std::error_code& ec); GHC_FS_API path proximate(const path& p, const path& base = current_path()); #endif GHC_FS_API path proximate(const path& p, const path& base, std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API path read_symlink(const path& p); #endif GHC_FS_API path read_symlink(const path& p, std::error_code& ec); GHC_FS_API path relative(const path& p, std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API path relative(const path& p, const path& base = current_path()); #endif GHC_FS_API path relative(const path& p, const path& base, std::error_code& ec); -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API bool remove(const path& p); #endif GHC_FS_API bool remove(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API uintmax_t remove_all(const path& p); #endif GHC_FS_API uintmax_t remove_all(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void rename(const path& from, const path& to); #endif GHC_FS_API void rename(const path& from, const path& to, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API void resize_file(const path& p, uintmax_t size); #endif GHC_FS_API void resize_file(const path& p, uintmax_t size, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API space_info space(const path& p); #endif GHC_FS_API space_info space(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API file_status status(const path& p); #endif GHC_FS_API file_status status(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool status_known(file_status s) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API file_status symlink_status(const path& p); #endif GHC_FS_API file_status symlink_status(const path& p, std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API path temp_directory_path(); #endif GHC_FS_API path temp_directory_path(std::error_code& ec) noexcept; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_FS_API path weakly_canonical(const path& p); #endif GHC_FS_API path weakly_canonical(const path& p, std::error_code& ec) noexcept; @@ -2171,7 +2171,7 @@ GHC_INLINE path::path(string_type&& source, format fmt) #endif // GHC_EXPAND_IMPL -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) template inline path::path(const Source& source, const std::locale& loc, format fmt) : path(source, fmt) @@ -3179,7 +3179,7 @@ GHC_INLINE const char* filesystem_error::what() const noexcept //----------------------------------------------------------------------------- // 30.10.15, filesystem operations -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path absolute(const path& p) { std::error_code ec; @@ -3240,7 +3240,7 @@ GHC_INLINE path absolute(const path& p, std::error_code& ec) #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path canonical(const path& p) { std::error_code ec; @@ -3315,7 +3315,7 @@ GHC_INLINE path canonical(const path& p, std::error_code& ec) return result; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void copy(const path& from, const path& to) { copy(from, to, copy_options::none); @@ -3327,7 +3327,7 @@ GHC_INLINE void copy(const path& from, const path& to, std::error_code& ec) noex copy(from, to, copy_options::none, ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void copy(const path& from, const path& to, copy_options options) { std::error_code ec; @@ -3414,7 +3414,7 @@ GHC_INLINE void copy(const path& from, const path& to, copy_options options, std return; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool copy_file(const path& from, const path& to) { return copy_file(from, to, copy_options::none); @@ -3426,7 +3426,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, std::error_code& ec) return copy_file(from, to, copy_options::none, ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool copy_file(const path& from, const path& to, copy_options option) { std::error_code ec; @@ -3512,7 +3512,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink) { std::error_code ec; @@ -3537,7 +3537,7 @@ GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symli } } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool create_directories(const path& p) { std::error_code ec; @@ -3586,7 +3586,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept return didCreate; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool create_directory(const path& p) { std::error_code ec; @@ -3603,7 +3603,7 @@ GHC_INLINE bool create_directory(const path& p, std::error_code& ec) noexcept return create_directory(p, path(), ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool create_directory(const path& p, const path& attributes) { std::error_code ec; @@ -3658,7 +3658,7 @@ GHC_INLINE bool create_directory(const path& p, const path& attributes, std::err return true; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink) { std::error_code ec; @@ -3674,7 +3674,7 @@ GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink detail::create_symlink(to, new_symlink, true, ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link) { std::error_code ec; @@ -3690,7 +3690,7 @@ GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link, std: detail::create_hardlink(to, new_hard_link, ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void create_symlink(const path& to, const path& new_symlink) { std::error_code ec; @@ -3706,7 +3706,7 @@ GHC_INLINE void create_symlink(const path& to, const path& new_symlink, std::err detail::create_symlink(to, new_symlink, false, ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path current_path() { std::error_code ec; @@ -3740,7 +3740,7 @@ GHC_INLINE path current_path(std::error_code& ec) #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void current_path(const path& p) { std::error_code ec; @@ -3770,7 +3770,7 @@ GHC_INLINE bool exists(file_status s) noexcept return status_known(s) && s.type() != file_type::not_found; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool exists(const path& p) { return exists(status(p)); @@ -3786,7 +3786,7 @@ GHC_INLINE bool exists(const path& p, std::error_code& ec) noexcept return exists(s); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool equivalent(const path& p1, const path& p2) { std::error_code ec; @@ -3845,7 +3845,7 @@ GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE uintmax_t file_size(const path& p) { std::error_code ec; @@ -3877,7 +3877,7 @@ GHC_INLINE uintmax_t file_size(const path& p, std::error_code& ec) noexcept #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE uintmax_t hard_link_count(const path& p) { std::error_code ec; @@ -3923,7 +3923,7 @@ GHC_INLINE bool is_block_file(file_status s) noexcept return s.type() == file_type::block; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_block_file(const path& p) { return is_block_file(status(p)); @@ -3940,7 +3940,7 @@ GHC_INLINE bool is_character_file(file_status s) noexcept return s.type() == file_type::character; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_character_file(const path& p) { return is_character_file(status(p)); @@ -3957,7 +3957,7 @@ GHC_INLINE bool is_directory(file_status s) noexcept return s.type() == file_type::directory; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_directory(const path& p) { return is_directory(status(p)); @@ -3969,7 +3969,7 @@ GHC_INLINE bool is_directory(const path& p, std::error_code& ec) noexcept return is_directory(status(p, ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_empty(const path& p) { if (is_directory(p)) { @@ -4008,7 +4008,7 @@ GHC_INLINE bool is_fifo(file_status s) noexcept return s.type() == file_type::fifo; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_fifo(const path& p) { return is_fifo(status(p)); @@ -4025,7 +4025,7 @@ GHC_INLINE bool is_other(file_status s) noexcept return exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_other(const path& p) { return is_other(status(p)); @@ -4042,7 +4042,7 @@ GHC_INLINE bool is_regular_file(file_status s) noexcept return s.type() == file_type::regular; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_regular_file(const path& p) { return is_regular_file(status(p)); @@ -4059,7 +4059,7 @@ GHC_INLINE bool is_socket(file_status s) noexcept return s.type() == file_type::socket; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_socket(const path& p) { return is_socket(status(p)); @@ -4076,7 +4076,7 @@ GHC_INLINE bool is_symlink(file_status s) noexcept return s.type() == file_type::symlink; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool is_symlink(const path& p) { return is_symlink(symlink_status(p)); @@ -4088,7 +4088,7 @@ GHC_INLINE bool is_symlink(const path& p, std::error_code& ec) noexcept return is_symlink(symlink_status(p, ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE file_time_type last_write_time(const path& p) { std::error_code ec; @@ -4108,7 +4108,7 @@ GHC_INLINE file_time_type last_write_time(const path& p, std::error_code& ec) no return ec ? (file_time_type::min)() : std::chrono::system_clock::from_time_t(result); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void last_write_time(const path& p, file_time_type new_time) { std::error_code ec; @@ -4173,7 +4173,7 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void permissions(const path& p, perms prms, perm_options opts) { std::error_code ec; @@ -4235,14 +4235,14 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::e #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path proximate(const path& p, std::error_code& ec) { return proximate(p, current_path(), ec); } #endif -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path proximate(const path& p, const path& base) { return weakly_canonical(p).lexically_proximate(weakly_canonical(base)); @@ -4254,7 +4254,7 @@ GHC_INLINE path proximate(const path& p, const path& base, std::error_code& ec) return weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path read_symlink(const path& p) { std::error_code ec; @@ -4282,7 +4282,7 @@ GHC_INLINE path relative(const path& p, std::error_code& ec) return relative(p, current_path(ec), ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path relative(const path& p, const path& base) { return weakly_canonical(p).lexically_relative(weakly_canonical(base)); @@ -4294,7 +4294,7 @@ GHC_INLINE path relative(const path& p, const path& base, std::error_code& ec) return weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool remove(const path& p) { std::error_code ec; @@ -4343,7 +4343,7 @@ GHC_INLINE bool remove(const path& p, std::error_code& ec) noexcept return ec ? false : true; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE uintmax_t remove_all(const path& p) { std::error_code ec; @@ -4400,7 +4400,7 @@ GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept return count; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void rename(const path& from, const path& to) { std::error_code ec; @@ -4429,7 +4429,7 @@ GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) no #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void resize_file(const path& p, uintmax_t size) { std::error_code ec; @@ -4468,7 +4468,7 @@ GHC_INLINE void resize_file(const path& p, uintmax_t size, std::error_code& ec) #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE space_info space(const path& p) { std::error_code ec; @@ -4506,7 +4506,7 @@ GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE file_status status(const path& p) { std::error_code ec; @@ -4528,7 +4528,7 @@ GHC_INLINE bool status_known(file_status s) noexcept return s.type() != file_type::none; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE file_status symlink_status(const path& p) { std::error_code ec; @@ -4545,7 +4545,7 @@ GHC_INLINE file_status symlink_status(const path& p, std::error_code& ec) noexce return detail::symlink_status_ex(p, ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path temp_directory_path() { std::error_code ec; @@ -4581,7 +4581,7 @@ GHC_INLINE path temp_directory_path(std::error_code& ec) noexcept #endif } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE path weakly_canonical(const path& p) { std::error_code ec; @@ -4703,7 +4703,7 @@ GHC_INLINE perms file_status::permissions() const noexcept // directory_entry::directory_entry() noexcept = default; // directory_entry::directory_entry(const directory_entry&) = default; // directory_entry::directory_entry(directory_entry&&) noexcept = default; -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE directory_entry::directory_entry(const filesystem::path& p) : _path(p) , _file_size(0) @@ -4734,7 +4734,7 @@ GHC_INLINE directory_entry::~directory_entry() {} // directory_entry& directory_entry::operator=(directory_entry&&) noexcept = default; // 30.10.12.2 directory_entry modifiers -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void directory_entry::assign(const filesystem::path& p) { _path = p; @@ -4748,7 +4748,7 @@ GHC_INLINE void directory_entry::assign(const filesystem::path& p, std::error_co refresh(ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p) { _path.replace_filename(p); @@ -4762,7 +4762,7 @@ GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p, std refresh(ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void directory_entry::refresh() { std::error_code ec; @@ -4793,7 +4793,7 @@ GHC_INLINE directory_entry::operator const filesystem::path&() const noexcept return _path; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::exists() const { return filesystem::exists(status()); @@ -4805,7 +4805,7 @@ GHC_INLINE bool directory_entry::exists(std::error_code& ec) const noexcept return filesystem::exists(status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::is_block_file() const { return filesystem::is_block_file(status()); @@ -4816,7 +4816,7 @@ GHC_INLINE bool directory_entry::is_block_file(std::error_code& ec) const noexce return filesystem::is_block_file(status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::is_character_file() const { return filesystem::is_character_file(status()); @@ -4828,7 +4828,7 @@ GHC_INLINE bool directory_entry::is_character_file(std::error_code& ec) const no return filesystem::is_character_file(status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::is_directory() const { return filesystem::is_directory(status()); @@ -4840,7 +4840,7 @@ GHC_INLINE bool directory_entry::is_directory(std::error_code& ec) const noexcep return filesystem::is_directory(status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::is_fifo() const { return filesystem::is_fifo(status()); @@ -4852,7 +4852,7 @@ GHC_INLINE bool directory_entry::is_fifo(std::error_code& ec) const noexcept return filesystem::is_fifo(status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::is_other() const { return filesystem::is_other(status()); @@ -4864,7 +4864,7 @@ GHC_INLINE bool directory_entry::is_other(std::error_code& ec) const noexcept return filesystem::is_other(status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::is_regular_file() const { return filesystem::is_regular_file(status()); @@ -4876,7 +4876,7 @@ GHC_INLINE bool directory_entry::is_regular_file(std::error_code& ec) const noex return filesystem::is_regular_file(status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::is_socket() const { return filesystem::is_socket(status()); @@ -4888,7 +4888,7 @@ GHC_INLINE bool directory_entry::is_socket(std::error_code& ec) const noexcept return filesystem::is_socket(status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE bool directory_entry::is_symlink() const { return filesystem::is_symlink(symlink_status()); @@ -4900,7 +4900,7 @@ GHC_INLINE bool directory_entry::is_symlink(std::error_code& ec) const noexcept return filesystem::is_symlink(symlink_status(ec)); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE uintmax_t directory_entry::file_size() const { if (_status.type() != file_type::none) { @@ -4919,7 +4919,7 @@ GHC_INLINE uintmax_t directory_entry::file_size(std::error_code& ec) const noexc return filesystem::file_size(path(), ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE uintmax_t directory_entry::hard_link_count() const { #ifndef GHC_OS_WINDOWS @@ -4942,7 +4942,7 @@ GHC_INLINE uintmax_t directory_entry::hard_link_count(std::error_code& ec) const return filesystem::hard_link_count(path(), ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE file_time_type directory_entry::last_write_time() const { if (_status.type() != file_type::none) { @@ -4961,7 +4961,7 @@ GHC_INLINE file_time_type directory_entry::last_write_time(std::error_code& ec) return filesystem::last_write_time(path(), ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE file_status directory_entry::status() const { if (_status.type() != file_type::none) { @@ -4980,7 +4980,7 @@ GHC_INLINE file_status directory_entry::status(std::error_code& ec) const noexce return filesystem::status(path(), ec); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE file_status directory_entry::symlink_status() const { if (_symlink_status.type() != file_type::none) { @@ -5201,7 +5201,7 @@ GHC_INLINE directory_iterator::directory_iterator() noexcept { } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE directory_iterator::directory_iterator(const path& p) : _impl(new impl(p, directory_options::none)) { @@ -5270,7 +5270,7 @@ GHC_INLINE const directory_entry* directory_iterator::operator->() const return &_impl->_dir_entry; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE directory_iterator& directory_iterator::operator++() { std::error_code ec; @@ -5319,7 +5319,7 @@ GHC_INLINE recursive_directory_iterator::recursive_directory_iterator() noexcept _impl->_dir_iter_stack.push(directory_iterator()); } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p) : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { @@ -5396,7 +5396,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator= return *this; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator++() { std::error_code ec; @@ -5433,7 +5433,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment return *this; } -#ifdef __cpp_exceptions +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) GHC_INLINE void recursive_directory_iterator::pop() { std::error_code ec; From 498dd371fa415879046c37dc7154901358db9214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Tue, 7 Apr 2020 15:40:27 +0800 Subject: [PATCH 5/6] merge all ifdef --- include/ghc/filesystem.hpp | 278 +++++++++++++++++++------------------ 1 file changed, 141 insertions(+), 137 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 9ff04a6..47f61fb 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -182,6 +182,10 @@ // ghc::filesystem version in decimal (major * 10000 + minor * 100 + patch) #define GHC_FILESYSTEM_VERSION 10302L +#if !defined(GHC_WITH_EXCEPTIONS) && (defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)) +#define GHC_WITH_EXCEPTIONS +#endif + namespace ghc { namespace filesystem { @@ -278,7 +282,7 @@ class GHC_FS_API_CLASS path path(const Source& source, format fmt = auto_format); template path(InputIterator first, InputIterator last, format fmt = auto_format); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS template > path(const Source& source, const std::locale& loc, format fmt = auto_format); template @@ -619,7 +623,7 @@ class GHC_FS_API_CLASS directory_entry directory_entry() noexcept = default; directory_entry(const directory_entry&) = default; directory_entry(directory_entry&&) noexcept = default; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS explicit directory_entry(const path& p); #endif directory_entry(const path& p, std::error_code& ec); @@ -630,15 +634,15 @@ class GHC_FS_API_CLASS directory_entry directory_entry& operator=(directory_entry&&) noexcept = default; // 30.10.12.2 modifiers -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS void assign(const path& p); #endif void assign(const path& p, std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS void replace_filename(const path& p); #endif void replace_filename(const path& p, std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS void refresh(); #endif void refresh(std::error_code& ec) noexcept; @@ -646,61 +650,61 @@ class GHC_FS_API_CLASS directory_entry // 30.10.12.3 observers const filesystem::path& path() const noexcept; operator const filesystem::path&() const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool exists() const; #endif bool exists(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool is_block_file() const; #endif bool is_block_file(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool is_character_file() const; #endif bool is_character_file(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool is_directory() const; #endif bool is_directory(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool is_fifo() const; #endif bool is_fifo(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool is_other() const; #endif bool is_other(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool is_regular_file() const; #endif bool is_regular_file(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool is_socket() const; #endif bool is_socket(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS bool is_symlink() const; #endif bool is_symlink(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS uintmax_t file_size() const; #endif uintmax_t file_size(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS uintmax_t hard_link_count() const; #endif uintmax_t hard_link_count(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS file_time_type last_write_time() const; #endif file_time_type last_write_time(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS file_status status() const; #endif file_status status(std::error_code& ec) const noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS file_status symlink_status() const; #endif file_status symlink_status(std::error_code& ec) const noexcept; @@ -750,7 +754,7 @@ class GHC_FS_API_CLASS directory_iterator // 30.10.13.1 member functions directory_iterator() noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS explicit directory_iterator(const path& p); directory_iterator(const path& p, directory_options options); #endif @@ -763,13 +767,13 @@ class GHC_FS_API_CLASS directory_iterator directory_iterator& operator=(directory_iterator&& rhs) noexcept; const directory_entry& operator*() const; const directory_entry* operator->() const; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS directory_iterator& operator++(); #endif directory_iterator& increment(std::error_code& ec) noexcept; // other members as required by 27.2.3, input iterators -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS proxy operator++(int) { proxy p{**this}; @@ -802,7 +806,7 @@ class GHC_FS_API_CLASS recursive_directory_iterator // 30.10.14.1 constructors and destructor recursive_directory_iterator() noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS explicit recursive_directory_iterator(const path& p); recursive_directory_iterator(const path& p, directory_options options); #endif @@ -823,19 +827,19 @@ class GHC_FS_API_CLASS recursive_directory_iterator // 30.10.14.1 modifiers recursive_directory_iterator& recursive_directory_iterator& operator=(const recursive_directory_iterator& rhs); recursive_directory_iterator& operator=(recursive_directory_iterator&& rhs) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS recursive_directory_iterator& operator++(); #endif recursive_directory_iterator& increment(std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS void pop(); #endif void pop(std::error_code& ec); void disable_recursion_pending(); // other members as required by 27.2.3, input iterators -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS directory_iterator::proxy operator++(int) { directory_iterator::proxy proxy{**this}; @@ -866,219 +870,219 @@ GHC_FS_API recursive_directory_iterator begin(recursive_directory_iterator iter) GHC_FS_API recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; // 30.10.15 filesystem operations -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path absolute(const path& p); #endif GHC_FS_API path absolute(const path& p, std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path canonical(const path& p); #endif GHC_FS_API path canonical(const path& p, std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void copy(const path& from, const path& to); #endif GHC_FS_API void copy(const path& from, const path& to, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void copy(const path& from, const path& to, copy_options options); #endif GHC_FS_API void copy(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool copy_file(const path& from, const path& to); #endif GHC_FS_API bool copy_file(const path& from, const path& to, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option); #endif GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink); #endif GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool create_directories(const path& p); #endif GHC_FS_API bool create_directories(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool create_directory(const path& p); #endif GHC_FS_API bool create_directory(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool create_directory(const path& p, const path& attributes); #endif GHC_FS_API bool create_directory(const path& p, const path& attributes, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink); #endif GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link); #endif GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void create_symlink(const path& to, const path& new_symlink); #endif GHC_FS_API void create_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path current_path(); #endif GHC_FS_API path current_path(std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void current_path(const path& p); #endif GHC_FS_API void current_path(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool exists(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool exists(const path& p); #endif GHC_FS_API bool exists(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool equivalent(const path& p1, const path& p2); #endif GHC_FS_API bool equivalent(const path& p1, const path& p2, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API uintmax_t file_size(const path& p); #endif GHC_FS_API uintmax_t file_size(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API uintmax_t hard_link_count(const path& p); #endif GHC_FS_API uintmax_t hard_link_count(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_block_file(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_block_file(const path& p); #endif GHC_FS_API bool is_block_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_character_file(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_character_file(const path& p); #endif GHC_FS_API bool is_character_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_directory(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_directory(const path& p); #endif GHC_FS_API bool is_directory(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_empty(const path& p); #endif GHC_FS_API bool is_empty(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_fifo(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_fifo(const path& p); #endif GHC_FS_API bool is_fifo(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_other(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_other(const path& p); #endif GHC_FS_API bool is_other(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_regular_file(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_regular_file(const path& p); #endif GHC_FS_API bool is_regular_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_socket(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_socket(const path& p); #endif GHC_FS_API bool is_socket(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_symlink(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_symlink(const path& p); #endif GHC_FS_API bool is_symlink(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API file_time_type last_write_time(const path& p); #endif GHC_FS_API file_time_type last_write_time(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void last_write_time(const path& p, file_time_type new_time); #endif GHC_FS_API void last_write_time(const path& p, file_time_type new_time, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void permissions(const path& p, perms prms, perm_options opts = perm_options::replace); #endif GHC_FS_API void permissions(const path& p, perms prms, std::error_code& ec) noexcept; GHC_FS_API void permissions(const path& p, perms prms, perm_options opts, std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path proximate(const path& p, std::error_code& ec); GHC_FS_API path proximate(const path& p, const path& base = current_path()); #endif GHC_FS_API path proximate(const path& p, const path& base, std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path read_symlink(const path& p); #endif GHC_FS_API path read_symlink(const path& p, std::error_code& ec); GHC_FS_API path relative(const path& p, std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path relative(const path& p, const path& base = current_path()); #endif GHC_FS_API path relative(const path& p, const path& base, std::error_code& ec); -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool remove(const path& p); #endif GHC_FS_API bool remove(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API uintmax_t remove_all(const path& p); #endif GHC_FS_API uintmax_t remove_all(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void rename(const path& from, const path& to); #endif GHC_FS_API void rename(const path& from, const path& to, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void resize_file(const path& p, uintmax_t size); #endif GHC_FS_API void resize_file(const path& p, uintmax_t size, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API space_info space(const path& p); #endif GHC_FS_API space_info space(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API file_status status(const path& p); #endif GHC_FS_API file_status status(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool status_known(file_status s) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API file_status symlink_status(const path& p); #endif GHC_FS_API file_status symlink_status(const path& p, std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path temp_directory_path(); #endif GHC_FS_API path temp_directory_path(std::error_code& ec) noexcept; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path weakly_canonical(const path& p); #endif GHC_FS_API path weakly_canonical(const path& p, std::error_code& ec) noexcept; @@ -2171,7 +2175,7 @@ GHC_INLINE path::path(string_type&& source, format fmt) #endif // GHC_EXPAND_IMPL -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS template inline path::path(const Source& source, const std::locale& loc, format fmt) : path(source, fmt) @@ -3179,7 +3183,7 @@ GHC_INLINE const char* filesystem_error::what() const noexcept //----------------------------------------------------------------------------- // 30.10.15, filesystem operations -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path absolute(const path& p) { std::error_code ec; @@ -3240,7 +3244,7 @@ GHC_INLINE path absolute(const path& p, std::error_code& ec) #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path canonical(const path& p) { std::error_code ec; @@ -3315,7 +3319,7 @@ GHC_INLINE path canonical(const path& p, std::error_code& ec) return result; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void copy(const path& from, const path& to) { copy(from, to, copy_options::none); @@ -3327,7 +3331,7 @@ GHC_INLINE void copy(const path& from, const path& to, std::error_code& ec) noex copy(from, to, copy_options::none, ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void copy(const path& from, const path& to, copy_options options) { std::error_code ec; @@ -3414,7 +3418,7 @@ GHC_INLINE void copy(const path& from, const path& to, copy_options options, std return; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool copy_file(const path& from, const path& to) { return copy_file(from, to, copy_options::none); @@ -3426,7 +3430,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, std::error_code& ec) return copy_file(from, to, copy_options::none, ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool copy_file(const path& from, const path& to, copy_options option) { std::error_code ec; @@ -3512,7 +3516,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink) { std::error_code ec; @@ -3537,7 +3541,7 @@ GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symli } } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directories(const path& p) { std::error_code ec; @@ -3586,7 +3590,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept return didCreate; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directory(const path& p) { std::error_code ec; @@ -3603,7 +3607,7 @@ GHC_INLINE bool create_directory(const path& p, std::error_code& ec) noexcept return create_directory(p, path(), ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directory(const path& p, const path& attributes) { std::error_code ec; @@ -3658,7 +3662,7 @@ GHC_INLINE bool create_directory(const path& p, const path& attributes, std::err return true; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink) { std::error_code ec; @@ -3674,7 +3678,7 @@ GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink detail::create_symlink(to, new_symlink, true, ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link) { std::error_code ec; @@ -3690,7 +3694,7 @@ GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link, std: detail::create_hardlink(to, new_hard_link, ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void create_symlink(const path& to, const path& new_symlink) { std::error_code ec; @@ -3706,7 +3710,7 @@ GHC_INLINE void create_symlink(const path& to, const path& new_symlink, std::err detail::create_symlink(to, new_symlink, false, ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path current_path() { std::error_code ec; @@ -3740,7 +3744,7 @@ GHC_INLINE path current_path(std::error_code& ec) #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void current_path(const path& p) { std::error_code ec; @@ -3770,7 +3774,7 @@ GHC_INLINE bool exists(file_status s) noexcept return status_known(s) && s.type() != file_type::not_found; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool exists(const path& p) { return exists(status(p)); @@ -3786,7 +3790,7 @@ GHC_INLINE bool exists(const path& p, std::error_code& ec) noexcept return exists(s); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool equivalent(const path& p1, const path& p2) { std::error_code ec; @@ -3845,7 +3849,7 @@ GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t file_size(const path& p) { std::error_code ec; @@ -3877,7 +3881,7 @@ GHC_INLINE uintmax_t file_size(const path& p, std::error_code& ec) noexcept #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t hard_link_count(const path& p) { std::error_code ec; @@ -3923,7 +3927,7 @@ GHC_INLINE bool is_block_file(file_status s) noexcept return s.type() == file_type::block; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_block_file(const path& p) { return is_block_file(status(p)); @@ -3940,7 +3944,7 @@ GHC_INLINE bool is_character_file(file_status s) noexcept return s.type() == file_type::character; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_character_file(const path& p) { return is_character_file(status(p)); @@ -3957,7 +3961,7 @@ GHC_INLINE bool is_directory(file_status s) noexcept return s.type() == file_type::directory; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_directory(const path& p) { return is_directory(status(p)); @@ -3969,7 +3973,7 @@ GHC_INLINE bool is_directory(const path& p, std::error_code& ec) noexcept return is_directory(status(p, ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_empty(const path& p) { if (is_directory(p)) { @@ -4008,7 +4012,7 @@ GHC_INLINE bool is_fifo(file_status s) noexcept return s.type() == file_type::fifo; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_fifo(const path& p) { return is_fifo(status(p)); @@ -4025,7 +4029,7 @@ GHC_INLINE bool is_other(file_status s) noexcept return exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_other(const path& p) { return is_other(status(p)); @@ -4042,7 +4046,7 @@ GHC_INLINE bool is_regular_file(file_status s) noexcept return s.type() == file_type::regular; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_regular_file(const path& p) { return is_regular_file(status(p)); @@ -4059,7 +4063,7 @@ GHC_INLINE bool is_socket(file_status s) noexcept return s.type() == file_type::socket; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_socket(const path& p) { return is_socket(status(p)); @@ -4076,7 +4080,7 @@ GHC_INLINE bool is_symlink(file_status s) noexcept return s.type() == file_type::symlink; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_symlink(const path& p) { return is_symlink(symlink_status(p)); @@ -4088,7 +4092,7 @@ GHC_INLINE bool is_symlink(const path& p, std::error_code& ec) noexcept return is_symlink(symlink_status(p, ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_time_type last_write_time(const path& p) { std::error_code ec; @@ -4108,7 +4112,7 @@ GHC_INLINE file_time_type last_write_time(const path& p, std::error_code& ec) no return ec ? (file_time_type::min)() : std::chrono::system_clock::from_time_t(result); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void last_write_time(const path& p, file_time_type new_time) { std::error_code ec; @@ -4173,7 +4177,7 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void permissions(const path& p, perms prms, perm_options opts) { std::error_code ec; @@ -4235,14 +4239,14 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::e #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path proximate(const path& p, std::error_code& ec) { return proximate(p, current_path(), ec); } #endif -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path proximate(const path& p, const path& base) { return weakly_canonical(p).lexically_proximate(weakly_canonical(base)); @@ -4254,7 +4258,7 @@ GHC_INLINE path proximate(const path& p, const path& base, std::error_code& ec) return weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path read_symlink(const path& p) { std::error_code ec; @@ -4282,7 +4286,7 @@ GHC_INLINE path relative(const path& p, std::error_code& ec) return relative(p, current_path(ec), ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path relative(const path& p, const path& base) { return weakly_canonical(p).lexically_relative(weakly_canonical(base)); @@ -4294,7 +4298,7 @@ GHC_INLINE path relative(const path& p, const path& base, std::error_code& ec) return weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool remove(const path& p) { std::error_code ec; @@ -4343,7 +4347,7 @@ GHC_INLINE bool remove(const path& p, std::error_code& ec) noexcept return ec ? false : true; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t remove_all(const path& p) { std::error_code ec; @@ -4400,7 +4404,7 @@ GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept return count; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void rename(const path& from, const path& to) { std::error_code ec; @@ -4429,7 +4433,7 @@ GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) no #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void resize_file(const path& p, uintmax_t size) { std::error_code ec; @@ -4468,7 +4472,7 @@ GHC_INLINE void resize_file(const path& p, uintmax_t size, std::error_code& ec) #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE space_info space(const path& p) { std::error_code ec; @@ -4506,7 +4510,7 @@ GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status status(const path& p) { std::error_code ec; @@ -4528,7 +4532,7 @@ GHC_INLINE bool status_known(file_status s) noexcept return s.type() != file_type::none; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status symlink_status(const path& p) { std::error_code ec; @@ -4545,7 +4549,7 @@ GHC_INLINE file_status symlink_status(const path& p, std::error_code& ec) noexce return detail::symlink_status_ex(p, ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path temp_directory_path() { std::error_code ec; @@ -4581,7 +4585,7 @@ GHC_INLINE path temp_directory_path(std::error_code& ec) noexcept #endif } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path weakly_canonical(const path& p) { std::error_code ec; @@ -4703,7 +4707,7 @@ GHC_INLINE perms file_status::permissions() const noexcept // directory_entry::directory_entry() noexcept = default; // directory_entry::directory_entry(const directory_entry&) = default; // directory_entry::directory_entry(directory_entry&&) noexcept = default; -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_entry::directory_entry(const filesystem::path& p) : _path(p) , _file_size(0) @@ -4734,7 +4738,7 @@ GHC_INLINE directory_entry::~directory_entry() {} // directory_entry& directory_entry::operator=(directory_entry&&) noexcept = default; // 30.10.12.2 directory_entry modifiers -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void directory_entry::assign(const filesystem::path& p) { _path = p; @@ -4748,7 +4752,7 @@ GHC_INLINE void directory_entry::assign(const filesystem::path& p, std::error_co refresh(ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p) { _path.replace_filename(p); @@ -4762,7 +4766,7 @@ GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p, std refresh(ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void directory_entry::refresh() { std::error_code ec; @@ -4793,7 +4797,7 @@ GHC_INLINE directory_entry::operator const filesystem::path&() const noexcept return _path; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::exists() const { return filesystem::exists(status()); @@ -4805,7 +4809,7 @@ GHC_INLINE bool directory_entry::exists(std::error_code& ec) const noexcept return filesystem::exists(status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_block_file() const { return filesystem::is_block_file(status()); @@ -4816,7 +4820,7 @@ GHC_INLINE bool directory_entry::is_block_file(std::error_code& ec) const noexce return filesystem::is_block_file(status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_character_file() const { return filesystem::is_character_file(status()); @@ -4828,7 +4832,7 @@ GHC_INLINE bool directory_entry::is_character_file(std::error_code& ec) const no return filesystem::is_character_file(status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_directory() const { return filesystem::is_directory(status()); @@ -4840,7 +4844,7 @@ GHC_INLINE bool directory_entry::is_directory(std::error_code& ec) const noexcep return filesystem::is_directory(status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_fifo() const { return filesystem::is_fifo(status()); @@ -4852,7 +4856,7 @@ GHC_INLINE bool directory_entry::is_fifo(std::error_code& ec) const noexcept return filesystem::is_fifo(status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_other() const { return filesystem::is_other(status()); @@ -4864,7 +4868,7 @@ GHC_INLINE bool directory_entry::is_other(std::error_code& ec) const noexcept return filesystem::is_other(status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_regular_file() const { return filesystem::is_regular_file(status()); @@ -4876,7 +4880,7 @@ GHC_INLINE bool directory_entry::is_regular_file(std::error_code& ec) const noex return filesystem::is_regular_file(status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_socket() const { return filesystem::is_socket(status()); @@ -4888,7 +4892,7 @@ GHC_INLINE bool directory_entry::is_socket(std::error_code& ec) const noexcept return filesystem::is_socket(status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_symlink() const { return filesystem::is_symlink(symlink_status()); @@ -4900,7 +4904,7 @@ GHC_INLINE bool directory_entry::is_symlink(std::error_code& ec) const noexcept return filesystem::is_symlink(symlink_status(ec)); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t directory_entry::file_size() const { if (_status.type() != file_type::none) { @@ -4919,7 +4923,7 @@ GHC_INLINE uintmax_t directory_entry::file_size(std::error_code& ec) const noexc return filesystem::file_size(path(), ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t directory_entry::hard_link_count() const { #ifndef GHC_OS_WINDOWS @@ -4942,7 +4946,7 @@ GHC_INLINE uintmax_t directory_entry::hard_link_count(std::error_code& ec) const return filesystem::hard_link_count(path(), ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_time_type directory_entry::last_write_time() const { if (_status.type() != file_type::none) { @@ -4961,7 +4965,7 @@ GHC_INLINE file_time_type directory_entry::last_write_time(std::error_code& ec) return filesystem::last_write_time(path(), ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status directory_entry::status() const { if (_status.type() != file_type::none) { @@ -4980,7 +4984,7 @@ GHC_INLINE file_status directory_entry::status(std::error_code& ec) const noexce return filesystem::status(path(), ec); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status directory_entry::symlink_status() const { if (_symlink_status.type() != file_type::none) { @@ -5201,7 +5205,7 @@ GHC_INLINE directory_iterator::directory_iterator() noexcept { } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_iterator::directory_iterator(const path& p) : _impl(new impl(p, directory_options::none)) { @@ -5270,7 +5274,7 @@ GHC_INLINE const directory_entry* directory_iterator::operator->() const return &_impl->_dir_entry; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_iterator& directory_iterator::operator++() { std::error_code ec; @@ -5319,7 +5323,7 @@ GHC_INLINE recursive_directory_iterator::recursive_directory_iterator() noexcept _impl->_dir_iter_stack.push(directory_iterator()); } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p) : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { @@ -5396,7 +5400,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator= return *this; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator++() { std::error_code ec; @@ -5433,7 +5437,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment return *this; } -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void recursive_directory_iterator::pop() { std::error_code ec; From ee9b432e3fe7b37e262b7f3e11ae18ae63bd83dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Tue, 7 Apr 2020 19:09:54 +0800 Subject: [PATCH 6/6] Fixed MinGW no-exception logic --- include/ghc/filesystem.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 47f61fb..bd2b5a9 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -5079,6 +5079,7 @@ class directory_iterator::impl do { if (FindNextFileW(_dirHandle, &_findData)) { _current = _base; +#ifdef GHC_RAISE_UNICODE_ERRORS try { _current.append_name(detail::toUtf8(_findData.cFileName).c_str()); } @@ -5086,6 +5087,9 @@ class directory_iterator::impl ec = fe.code(); return; } +#else + _current.append_name(detail::toUtf8(_findData.cFileName).c_str()); +#endif copyToDirEntry(ec); } else {