]> git.lyx.org Git - lyx.git/blob - boost/boost/filesystem/exception.hpp
boost::filesystem added
[lyx.git] / boost / boost / filesystem / exception.hpp
1 //  boost/filesystem/exception.hpp  ------------------------------------------//
2
3 // < ----------------------------------------------------------------------- > 
4 // <   Copyright © 2002 Beman Dawes                                          > 
5 // <   Copyright © 2001 Dietmar Kühl, All Rights Reserved                    > 
6 // <                                                                         > 
7 // <   Permission to use, copy, modify, distribute and sell this             > 
8 // <   software for any purpose is hereby granted without fee, provided      > 
9 // <   that the above copyright notice appears in all copies and that        > 
10 // <   both that copyright notice and this permission notice appear in       > 
11 // <   supporting documentation. The authors make no representations about   > 
12 // <   the suitability of this software for any purpose. It is provided      > 
13 // <   "as is" without express or implied warranty.                          > 
14 // < ----------------------------------------------------------------------- > 
15
16 //  See http://www.boost.org/libs/filesystem for documentation.
17
18 //----------------------------------------------------------------------------// 
19
20 #ifndef BOOST_FILESYSTEM_EXCEPTION_HPP
21 #define BOOST_FILESYSTEM_EXCEPTION_HPP
22
23 #include <boost/filesystem/path.hpp>
24
25 #include <string>
26 #include <stdexcept>
27
28 //----------------------------------------------------------------------------// 
29
30 namespace boost
31 {
32   namespace filesystem
33   {
34     namespace detail
35     {
36       int system_error_code(); // artifact of POSIX and WINDOWS error reporting
37     }
38
39     enum error_code
40     {
41       no_error = 0,
42       system_error,     // system generated error; if possible, is translated
43                         // to one of the more specific errors below.
44       other_error,      // library generated error
45       security_error,   // includes access rights, permissions failures
46       read_only_error,
47       io_error,
48       path_error,
49       not_found_error,
50       not_directory_error,
51       busy_error,       // implies trying again might succeed
52       already_exists_error,
53       not_empty_error,
54       is_directory_error,
55       out_of_space_error,
56       out_of_memory_error,
57       out_of_resource_error
58     };
59
60
61     class filesystem_error : public std::runtime_error
62     {
63     public:
64
65       filesystem_error(
66         const std::string & who,
67         const std::string & message ); // assumed to be error_code::other_error
68
69       filesystem_error(
70         const std::string & who,
71         const path & path1,
72         const std::string & message ); // assumed to be error_code::other_error
73
74       filesystem_error(
75         const std::string & who,
76         const path & path1,
77         int sys_err_code );
78
79       filesystem_error(
80         const std::string & who,
81         const path & path1,
82         const path & path2,
83         int sys_err_code );
84
85       ~filesystem_error() 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       int             m_sys_err;
96       error_code      m_err;
97       std::string     m_who;
98       path            m_path1;
99       path            m_path2;
100     };
101
102   } // namespace filesystem
103 } // namespace boost
104
105 #endif // BOOST_FILESYSTEM_EXCEPTION_HPP