1 // boost/filesystem/exception.hpp -----------------------------------------------------//
3 // Copyright Beman Dawes 2003
4 // Copyright Andrey Semashev 2019
6 // Distributed under the Boost Software License, Version 1.0.
7 // See http://www.boost.org/LICENSE_1_0.txt
9 // Library home page: http://www.boost.org/libs/filesystem
11 #ifndef BOOST_FILESYSTEM3_EXCEPTION_HPP
12 #define BOOST_FILESYSTEM3_EXCEPTION_HPP
14 #include <boost/config.hpp>
16 # if defined( BOOST_NO_STD_WSTRING )
17 # error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
20 #include <boost/filesystem/config.hpp>
21 #include <boost/filesystem/path.hpp>
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>
29 #include <boost/config/abi_prefix.hpp> // must be the last #include
31 #if defined(BOOST_MSVC)
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)
40 namespace filesystem {
42 //--------------------------------------------------------------------------------------//
44 // class filesystem_error //
46 //--------------------------------------------------------------------------------------//
48 class BOOST_FILESYSTEM_DECL filesystem_error :
49 public system::system_error
51 // see http://www.boost.org/more/error_handling.html for design rationale
54 filesystem_error(const std::string& what_arg, system::error_code ec);
55 filesystem_error(const std::string& what_arg, const path& path1_arg, system::error_code ec);
56 filesystem_error(const std::string& what_arg, const path& path1_arg, const path& path2_arg, system::error_code ec);
58 filesystem_error(filesystem_error const& that);
59 filesystem_error& operator= (filesystem_error const& that);
61 ~filesystem_error() BOOST_NOEXCEPT_OR_NOTHROW;
63 const path& path1() const BOOST_NOEXCEPT
65 return m_imp_ptr.get() ? m_imp_ptr->m_path1 : get_empty_path();
67 const path& path2() const BOOST_NOEXCEPT
69 return m_imp_ptr.get() ? m_imp_ptr->m_path2 : get_empty_path();
72 const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE;
75 static const path& get_empty_path() BOOST_NOEXCEPT;
79 public boost::intrusive_ref_counter< impl >
81 path m_path1; // may be empty()
82 path m_path2; // may be empty()
83 std::string m_what; // not built until needed
85 BOOST_DEFAULTED_FUNCTION(impl(), {})
86 explicit impl(path const& path1) : m_path1(path1) {}
87 impl(path const& path1, path const& path2) : m_path1(path1), m_path2(path2) {}
89 boost::intrusive_ptr< impl > m_imp_ptr;
92 } // namespace filesystem
95 #if defined(BOOST_MSVC)
99 #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
100 #endif // BOOST_FILESYSTEM3_EXCEPTION_HPP