source: NonGTP/Boost/boost/filesystem/exception.hpp @ 857

Revision 857, 3.4 KB checked in by igarcia, 19 years ago (diff)
Line 
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
28namespace 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,
71        error_code ec = other_error );
72
73      filesystem_error(
74        const std::string & who,
75        const path & path1,
76        int sys_err_code );
77
78      filesystem_error(
79        const std::string & who,
80        const path & path1,
81        const path & path2,
82        int sys_err_code );
83
84      ~filesystem_error() throw();
85
86      virtual const char * what() const throw();
87
88      int             native_error() const { return m_sys_err; }
89      // Note: a value of 0 implies a library (rather than system) error
90      error_code      error() const { return m_err; }
91      const std::string &  who() const; // name of who throwing exception
92      const path &    path1() const; // argument 1 to who; may be empty()
93      const path &    path2() const; // argument 2 to who; may be empty()
94
95    private:
96      class             m_imp;
97      shared_ptr<m_imp> m_imp_ptr;
98      int               m_sys_err;
99      error_code        m_err;
100    };
101
102  } // namespace filesystem
103} // namespace boost
104
105#include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
106#endif // BOOST_FILESYSTEM_EXCEPTION_HPP
Note: See TracBrowser for help on using the repository browser.