1 // boost/filesystem/exception.hpp -----------------------------------------------------// 2 3 // Copyright Beman Dawes 2003 4 // Copyright Andrey Semashev 2019 5 6 // Distributed under the Boost Software License, Version 1.0. 7 // See http://www.boost.org/LICENSE_1_0.txt 8 9 // Library home page: http://www.boost.org/libs/filesystem 10 11 #ifndef BOOST_FILESYSTEM3_EXCEPTION_HPP 12 #define BOOST_FILESYSTEM3_EXCEPTION_HPP 13 14 #include <boost/config.hpp> 15 16 # if defined( BOOST_NO_STD_WSTRING ) 17 # error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support 18 # endif 19 20 #include <boost/filesystem/config.hpp> 21 #include <boost/filesystem/path.hpp> 22 23 #include <string> 24 #include <boost/system/error_code.hpp> 25 #include <boost/system/system_error.hpp> 26 #include <boost/smart_ptr/intrusive_ptr.hpp> 27 #include <boost/smart_ptr/intrusive_ref_counter.hpp> 28 29 #include <boost/config/abi_prefix.hpp> // must be the last #include 30 31 #if defined(BOOST_MSVC) 32 #pragma warning(push) 33 // 'm_A' : class 'A' needs to have dll-interface to be used by clients of class 'B' 34 #pragma warning(disable: 4251) 35 // non dll-interface class 'A' used as base for dll-interface class 'B' 36 #pragma warning(disable: 4275) 37 #endif 38 39 namespace boost { 40 namespace filesystem { 41 42 //--------------------------------------------------------------------------------------// 43 // // 44 // class filesystem_error // 45 // // 46 //--------------------------------------------------------------------------------------// 47 48 class BOOST_SYMBOL_VISIBLE filesystem_error : 49 public system::system_error 50 { 51 // see http://www.boost.org/more/error_handling.html for design rationale 52 53 public: 54 BOOST_FILESYSTEM_DECL filesystem_error(const std::string& what_arg, system::error_code ec); 55 BOOST_FILESYSTEM_DECL filesystem_error(const std::string& what_arg, const path& path1_arg, system::error_code ec); 56 BOOST_FILESYSTEM_DECL filesystem_error(const std::string& what_arg, const path& path1_arg, const path& path2_arg, system::error_code ec); 57 58 BOOST_FILESYSTEM_DECL filesystem_error(filesystem_error const& that); 59 BOOST_FILESYSTEM_DECL filesystem_error& operator= (filesystem_error const& that); 60 61 BOOST_FILESYSTEM_DECL ~filesystem_error() BOOST_NOEXCEPT_OR_NOTHROW; 62 path1() const63 const path& path1() const BOOST_NOEXCEPT 64 { 65 return m_imp_ptr.get() ? m_imp_ptr->m_path1 : get_empty_path(); 66 } path2() const67 const path& path2() const BOOST_NOEXCEPT 68 { 69 return m_imp_ptr.get() ? m_imp_ptr->m_path2 : get_empty_path(); 70 } 71 72 BOOST_FILESYSTEM_DECL const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE; 73 74 private: 75 BOOST_FILESYSTEM_DECL static const path& get_empty_path() BOOST_NOEXCEPT; 76 77 private: 78 struct impl : 79 public boost::intrusive_ref_counter< impl > 80 { 81 path m_path1; // may be empty() 82 path m_path2; // may be empty() 83 std::string m_what; // not built until needed 84 implboost::filesystem::filesystem_error::impl85 BOOST_DEFAULTED_FUNCTION(impl(), {}) 86 explicit impl(path const& path1) : m_path1(path1) {} implboost::filesystem::filesystem_error::impl87 impl(path const& path1, path const& path2) : m_path1(path1), m_path2(path2) {} 88 }; 89 boost::intrusive_ptr< impl > m_imp_ptr; 90 }; 91 92 } // namespace filesystem 93 } // namespace boost 94 95 #if defined(BOOST_MSVC) 96 #pragma warning(pop) 97 #endif 98 99 #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas 100 #endif // BOOST_FILESYSTEM3_EXCEPTION_HPP 101