]> git.lyx.org Git - lyx.git/blob - boost/boost/filesystem/exception.hpp
884df03129f686a0d69cee288e7830b988beb463
[lyx.git] / boost / boost / filesystem / exception.hpp
1 //  boost/filesystem/exception.hpp  ------------------------------------------//
2
3 //  Copyright © 2002 Beman Dawes                                          
4 //  Copyright © 2001 Dietmar Kühl                                         
5 //                                                                        
6 //  Use, modification, and distribution is subject to the Boost Software 
7 //  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy 
8 //  at http://www.boost.org/LICENSE_1_0.txt)                             
9
10 //  See library home page at http://www.boost.org/libs/filesystem
11
12 //----------------------------------------------------------------------------// 
13
14 #ifndef BOOST_FILESYSTEM_EXCEPTION_HPP
15 #define BOOST_FILESYSTEM_EXCEPTION_HPP
16
17 #include <boost/filesystem/config.hpp>
18 #include <boost/filesystem/path.hpp>
19
20 #include <string>
21 #include <exception>
22 #include <boost/shared_ptr.hpp>
23
24 #include <boost/config/abi_prefix.hpp> // must be the last header
25
26 //----------------------------------------------------------------------------// 
27
28 namespace boost
29 {
30   namespace filesystem
31   {
32     namespace detail
33     {
34       BOOST_FILESYSTEM_DECL int system_error_code(); // artifact of POSIX and WINDOWS error reporting
35     }
36
37     enum error_code
38     {
39       no_error = 0,
40       system_error,     // system generated error; if possible, is translated
41                         // to one of the more specific errors below.
42       other_error,      // library generated error
43       security_error,   // includes access rights, permissions failures
44       read_only_error,
45       io_error,
46       path_error,
47       not_found_error,
48       not_directory_error,
49       busy_error,       // implies trying again might succeed
50       already_exists_error,
51       not_empty_error,
52       is_directory_error,
53       out_of_space_error,
54       out_of_memory_error,
55       out_of_resource_error
56     };
57
58
59     class BOOST_FILESYSTEM_DECL filesystem_error : public std::exception
60     {
61     public:
62
63       filesystem_error(
64         const std::string & who,
65         const std::string & message ); // assumed to be error_code::other_error
66
67       filesystem_error(
68         const std::string & who,
69         const path & path1,
70         const std::string & message ); // assumed to be error_code::other_error
71
72       filesystem_error(
73         const std::string & who,
74         const path & path1,
75         int sys_err_code );
76
77       filesystem_error(
78         const std::string & who,
79         const path & path1,
80         const path & path2,
81         int sys_err_code );
82
83       ~filesystem_error() throw();
84
85       virtual const char * what() const throw();
86
87       int             native_error() const { return m_sys_err; }
88       // Note: a value of 0 implies a library (rather than system) error
89       error_code      error() const { return m_err; }
90       const std::string &  who() const; // name of who throwing exception
91       const path &    path1() const; // argument 1 to who; may be empty()
92       const path &    path2() const; // argument 2 to who; may be empty()
93
94     private:
95       class             m_imp;
96       shared_ptr<m_imp> m_imp_ptr;
97       int               m_sys_err;
98       error_code        m_err;
99     };
100
101   } // namespace filesystem
102 } // namespace boost
103
104 #include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
105 #endif // BOOST_FILESYSTEM_EXCEPTION_HPP