diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 1f0fe39..bd2b5a9 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,10 +282,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 GHC_WITH_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 +623,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 GHC_WITH_EXCEPTIONS explicit directory_entry(const path& p); +#endif directory_entry(const path& p, std::error_code& ec); ~directory_entry(); @@ -626,45 +634,79 @@ class GHC_FS_API_CLASS directory_entry directory_entry& operator=(directory_entry&&) noexcept = default; // 30.10.12.2 modifiers +#ifdef GHC_WITH_EXCEPTIONS void assign(const path& p); +#endif void assign(const path& p, std::error_code& ec); +#ifdef GHC_WITH_EXCEPTIONS void replace_filename(const path& p); +#endif void replace_filename(const path& p, std::error_code& ec); +#ifdef GHC_WITH_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 GHC_WITH_EXCEPTIONS bool exists() const; +#endif bool exists(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS bool is_block_file() const; +#endif bool is_block_file(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS bool is_character_file() const; +#endif bool is_character_file(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS bool is_directory() const; +#endif bool is_directory(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS bool is_fifo() const; +#endif bool is_fifo(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS bool is_other() const; +#endif bool is_other(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS bool is_regular_file() const; +#endif bool is_regular_file(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS bool is_socket() const; +#endif bool is_socket(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS bool is_symlink() const; +#endif bool is_symlink(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS uintmax_t file_size() const; +#endif uintmax_t file_size(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS uintmax_t hard_link_count() const; +#endif uintmax_t hard_link_count(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS file_time_type last_write_time() const; +#endif file_time_type last_write_time(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_EXCEPTIONS file_status status() const; +#endif file_status status(std::error_code& ec) const noexcept; +#ifdef GHC_WITH_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 +754,10 @@ class GHC_FS_API_CLASS directory_iterator // 30.10.13.1 member functions directory_iterator() noexcept; +#ifdef GHC_WITH_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 +767,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 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 +#ifdef GHC_WITH_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 +806,10 @@ class GHC_FS_API_CLASS recursive_directory_iterator // 30.10.14.1 constructors and destructor recursive_directory_iterator() noexcept; +#ifdef GHC_WITH_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 +827,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 GHC_WITH_EXCEPTIONS recursive_directory_iterator& operator++(); +#endif recursive_directory_iterator& increment(std::error_code& ec) noexcept; +#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 +#ifdef GHC_WITH_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 +870,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 GHC_WITH_EXCEPTIONS GHC_FS_API path absolute(const path& p); +#endif GHC_FS_API path absolute(const path& p, std::error_code& ec); +#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); +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path current_path(); +#endif GHC_FS_API path current_path(std::error_code& ec); +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#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); +#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); +#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); +#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); +#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; +#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; +#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; +#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; +#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; +#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; +#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; +#ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path temp_directory_path(); +#endif GHC_FS_API path temp_directory_path(std::error_code& ec) noexcept; +#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; // Non-C++17 add-on std::fstream wrappers with path @@ -2033,6 +2175,7 @@ GHC_INLINE path::path(string_type&& source, format fmt) #endif // GHC_EXPAND_IMPL +#ifdef GHC_WITH_EXCEPTIONS template inline path::path(const Source& source, const std::locale& loc, format fmt) : path(source, fmt) @@ -2052,6 +2195,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 +3183,7 @@ GHC_INLINE const char* filesystem_error::what() const noexcept //----------------------------------------------------------------------------- // 30.10.15, filesystem operations +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path absolute(const path& p) { std::error_code ec; @@ -3048,6 +3193,7 @@ GHC_INLINE path absolute(const path& p) } return result; } +#endif GHC_INLINE path absolute(const path& p, std::error_code& ec) { @@ -3098,6 +3244,7 @@ GHC_INLINE path absolute(const path& p, std::error_code& ec) #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path canonical(const path& p) { std::error_code ec; @@ -3107,6 +3254,7 @@ GHC_INLINE path canonical(const path& p) } return result; } +#endif GHC_INLINE path canonical(const path& p, std::error_code& ec) { @@ -3171,16 +3319,19 @@ GHC_INLINE path canonical(const path& p, std::error_code& ec) return result; } +#ifdef GHC_WITH_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 { copy(from, to, copy_options::none, ec); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void copy(const path& from, const path& to, copy_options options) { std::error_code ec; @@ -3189,6 +3340,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 { @@ -3266,16 +3418,19 @@ GHC_INLINE void copy(const path& from, const path& to, copy_options options, std return; } +#ifdef GHC_WITH_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 { return copy_file(from, to, copy_options::none, ec); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool copy_file(const path& from, const path& to, copy_options option) { std::error_code ec; @@ -3285,6 +3440,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 +3516,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink) { std::error_code ec; @@ -3368,6 +3525,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 +3541,7 @@ GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symli } } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directories(const path& p) { std::error_code ec; @@ -3392,6 +3551,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 +3590,7 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept return didCreate; } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directory(const path& p) { std::error_code ec; @@ -3439,12 +3600,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 GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directory(const path& p, const path& attributes) { std::error_code ec; @@ -3454,6 +3617,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 +3662,7 @@ GHC_INLINE bool create_directory(const path& p, const path& attributes, std::err return true; } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink) { std::error_code ec; @@ -3506,12 +3671,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 GHC_WITH_EXCEPTIONS GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link) { std::error_code ec; @@ -3520,12 +3687,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 GHC_WITH_EXCEPTIONS GHC_INLINE void create_symlink(const path& to, const path& new_symlink) { std::error_code ec; @@ -3534,12 +3703,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 GHC_WITH_EXCEPTIONS GHC_INLINE path current_path() { std::error_code ec; @@ -3549,6 +3720,7 @@ GHC_INLINE path current_path() } return result; } +#endif GHC_INLINE path current_path(std::error_code& ec) { @@ -3572,6 +3744,7 @@ GHC_INLINE path current_path(std::error_code& ec) #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void current_path(const path& p) { std::error_code ec; @@ -3580,6 +3753,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 { @@ -3600,10 +3774,12 @@ GHC_INLINE bool exists(file_status s) noexcept return status_known(s) && s.type() != file_type::not_found; } +#ifdef GHC_WITH_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 { @@ -3614,6 +3790,7 @@ GHC_INLINE bool exists(const path& p, std::error_code& ec) noexcept return exists(s); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool equivalent(const path& p1, const path& p2) { std::error_code ec; @@ -3623,6 +3800,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 +3849,7 @@ GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t file_size(const path& p) { std::error_code ec; @@ -3680,6 +3859,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 +3881,7 @@ GHC_INLINE uintmax_t file_size(const path& p, std::error_code& ec) noexcept #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t hard_link_count(const path& p) { std::error_code ec; @@ -3710,6 +3891,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 { @@ -3745,10 +3927,12 @@ GHC_INLINE bool is_block_file(file_status s) noexcept return s.type() == file_type::block; } +#ifdef GHC_WITH_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 { @@ -3760,10 +3944,12 @@ GHC_INLINE bool is_character_file(file_status s) noexcept return s.type() == file_type::character; } +#ifdef GHC_WITH_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 { @@ -3775,16 +3961,19 @@ GHC_INLINE bool is_directory(file_status s) noexcept return s.type() == file_type::directory; } +#ifdef GHC_WITH_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 GHC_WITH_EXCEPTIONS GHC_INLINE bool is_empty(const path& p) { if (is_directory(p)) { @@ -3794,6 +3983,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 { @@ -3822,10 +4012,12 @@ GHC_INLINE bool is_fifo(file_status s) noexcept return s.type() == file_type::fifo; } +#ifdef GHC_WITH_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 { @@ -3837,10 +4029,12 @@ GHC_INLINE bool is_other(file_status s) noexcept return exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s); } +#ifdef GHC_WITH_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 { @@ -3852,10 +4046,12 @@ GHC_INLINE bool is_regular_file(file_status s) noexcept return s.type() == file_type::regular; } +#ifdef GHC_WITH_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 { @@ -3867,10 +4063,12 @@ GHC_INLINE bool is_socket(file_status s) noexcept return s.type() == file_type::socket; } +#ifdef GHC_WITH_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 { @@ -3882,16 +4080,19 @@ GHC_INLINE bool is_symlink(file_status s) noexcept return s.type() == file_type::symlink; } +#ifdef GHC_WITH_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 { return is_symlink(symlink_status(p, ec)); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_time_type last_write_time(const path& p) { std::error_code ec; @@ -3901,6 +4102,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 +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); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void last_write_time(const path& p, file_time_type new_time) { std::error_code ec; @@ -3918,6 +4121,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 +4177,7 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void permissions(const path& p, perms prms, perm_options opts) { std::error_code ec; @@ -3981,6 +4186,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 { @@ -4033,21 +4239,26 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::e #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path proximate(const path& p, std::error_code& ec) { return proximate(p, current_path(), ec); } +#endif +#ifdef GHC_WITH_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) { return weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec)); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path read_symlink(const path& p) { std::error_code ec; @@ -4057,6 +4268,7 @@ GHC_INLINE path read_symlink(const path& p) } return result; } +#endif GHC_INLINE path read_symlink(const path& p, std::error_code& ec) { @@ -4074,16 +4286,19 @@ GHC_INLINE path relative(const path& p, std::error_code& ec) return relative(p, current_path(ec), ec); } +#ifdef GHC_WITH_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) { return weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec)); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool remove(const path& p) { std::error_code ec; @@ -4093,6 +4308,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 +4347,7 @@ GHC_INLINE bool remove(const path& p, std::error_code& ec) noexcept return ec ? false : true; } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t remove_all(const path& p) { std::error_code ec; @@ -4140,6 +4357,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 { @@ -4156,7 +4374,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); @@ -4182,6 +4404,7 @@ GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept return count; } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void rename(const path& from, const path& to) { std::error_code ec; @@ -4190,6 +4413,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 +4433,7 @@ GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) no #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void resize_file(const path& p, uintmax_t size) { std::error_code ec; @@ -4217,6 +4442,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 +4472,7 @@ GHC_INLINE void resize_file(const path& p, uintmax_t size, std::error_code& ec) #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE space_info space(const path& p) { std::error_code ec; @@ -4255,6 +4482,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 +4510,7 @@ GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status status(const path& p) { std::error_code ec; @@ -4291,6 +4520,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 +4532,7 @@ GHC_INLINE bool status_known(file_status s) noexcept return s.type() != file_type::none; } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status symlink_status(const path& p) { std::error_code ec; @@ -4311,12 +4542,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 GHC_WITH_EXCEPTIONS GHC_INLINE path temp_directory_path() { std::error_code ec; @@ -4326,6 +4559,7 @@ GHC_INLINE path temp_directory_path() } return result; } +#endif GHC_INLINE path temp_directory_path(std::error_code& ec) noexcept { @@ -4351,6 +4585,7 @@ GHC_INLINE path temp_directory_path(std::error_code& ec) noexcept #endif } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path weakly_canonical(const path& p) { std::error_code ec; @@ -4360,6 +4595,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 { @@ -4471,6 +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; +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_entry::directory_entry(const filesystem::path& p) : _path(p) , _file_size(0) @@ -4481,6 +4718,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) @@ -4500,11 +4738,13 @@ GHC_INLINE directory_entry::~directory_entry() {} // directory_entry& directory_entry::operator=(directory_entry&&) noexcept = default; // 30.10.12.2 directory_entry modifiers +#ifdef GHC_WITH_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) { @@ -4512,11 +4752,13 @@ GHC_INLINE void directory_entry::assign(const filesystem::path& p, std::error_co refresh(ec); } +#ifdef GHC_WITH_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) { @@ -4524,6 +4766,7 @@ GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p, std refresh(ec); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void directory_entry::refresh() { std::error_code ec; @@ -4532,6 +4775,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 { @@ -4553,95 +4797,114 @@ GHC_INLINE directory_entry::operator const filesystem::path&() const noexcept return _path; } +#ifdef GHC_WITH_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 GHC_WITH_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 GHC_WITH_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 GHC_WITH_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 GHC_WITH_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 GHC_WITH_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 GHC_WITH_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 GHC_WITH_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 GHC_WITH_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 GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t directory_entry::file_size() const { if (_status.type() != file_type::none) { @@ -4649,6 +4912,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 { @@ -4659,6 +4923,7 @@ GHC_INLINE uintmax_t directory_entry::file_size(std::error_code& ec) const noexc return filesystem::file_size(path(), ec); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t directory_entry::hard_link_count() const { #ifndef GHC_OS_WINDOWS @@ -4668,6 +4933,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 { @@ -4680,6 +4946,7 @@ GHC_INLINE uintmax_t directory_entry::hard_link_count(std::error_code& ec) const return filesystem::hard_link_count(path(), ec); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_time_type directory_entry::last_write_time() const { if (_status.type() != file_type::none) { @@ -4687,6 +4954,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 { @@ -4697,6 +4965,7 @@ GHC_INLINE file_time_type directory_entry::last_write_time(std::error_code& ec) return filesystem::last_write_time(path(), ec); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status directory_entry::status() const { if (_status.type() != file_type::none) { @@ -4704,6 +4973,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 { @@ -4714,6 +4984,7 @@ GHC_INLINE file_status directory_entry::status(std::error_code& ec) const noexce return filesystem::status(path(), ec); } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status directory_entry::symlink_status() const { if (_symlink_status.type() != file_type::none) { @@ -4721,6 +4992,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 { @@ -4807,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()); } @@ -4814,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 { @@ -4933,6 +5209,7 @@ GHC_INLINE directory_iterator::directory_iterator() noexcept { } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_iterator::directory_iterator(const path& p) : _impl(new impl(p, directory_options::none)) { @@ -4949,6 +5226,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 +5278,7 @@ GHC_INLINE const directory_entry* directory_iterator::operator->() const return &_impl->_dir_entry; } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_iterator& directory_iterator::operator++() { std::error_code ec; @@ -5009,6 +5288,7 @@ GHC_INLINE directory_iterator& directory_iterator::operator++() } return *this; } +#endif GHC_INLINE directory_iterator& directory_iterator::increment(std::error_code& ec) noexcept { @@ -5047,6 +5327,7 @@ GHC_INLINE recursive_directory_iterator::recursive_directory_iterator() noexcept _impl->_dir_iter_stack.push(directory_iterator()); } +#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)) { @@ -5058,6 +5339,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)) @@ -5122,6 +5404,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator= return *this; } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator++() { std::error_code ec; @@ -5131,10 +5414,15 @@ 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 { - 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 { @@ -5153,6 +5441,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment return *this; } +#ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void recursive_directory_iterator::pop() { std::error_code ec; @@ -5161,6 +5450,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..9ad6842 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) +endif() +target_include_directories(exception PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) 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; +}