]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/filesystem/src/error_handling.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / filesystem / src / error_handling.hpp
CommitLineData
92f5a8d4
TL
1// error_handling.hpp --------------------------------------------------------------------//
2
3// Copyright 2002-2009, 2014 Beman Dawes
4// Copyright 2019 Andrey Semashev
5
6// Distributed under the Boost Software License, Version 1.0.
7// See http://www.boost.org/LICENSE_1_0.txt
8
9// See library home page at http://www.boost.org/libs/filesystem
10
11//--------------------------------------------------------------------------------------//
12
13#ifndef BOOST_FILESYSTEM3_SRC_ERROR_HANDLING_HPP_
14#define BOOST_FILESYSTEM3_SRC_ERROR_HANDLING_HPP_
15
16#include <cerrno>
17#include <boost/system/error_code.hpp>
18#include <boost/filesystem/config.hpp>
19#include <boost/filesystem/exception.hpp>
20
21#if defined(BOOST_WINDOWS_API)
22#include <boost/winapi/basic_types.hpp>
23#include <boost/winapi/get_last_error.hpp>
24#include <boost/winapi/error_codes.hpp>
25#endif
26
27namespace boost {
28namespace filesystem {
29
30#if defined(BOOST_POSIX_API)
31
32typedef int err_t;
33
34// POSIX uses a 0 return to indicate success
35#define BOOST_ERRNO errno
36
20effc67 37#define BOOST_ERROR_FILE_NOT_FOUND ENOENT
92f5a8d4 38#define BOOST_ERROR_ALREADY_EXISTS EEXIST
20effc67 39#define BOOST_ERROR_NOT_SUPPORTED ENOSYS
92f5a8d4
TL
40
41#else
42
43typedef boost::winapi::DWORD_ err_t;
44
45// Windows uses a non-0 return to indicate success
46#define BOOST_ERRNO boost::winapi::GetLastError()
47
20effc67 48#define BOOST_ERROR_FILE_NOT_FOUND boost::winapi::ERROR_FILE_NOT_FOUND_
92f5a8d4
TL
49#define BOOST_ERROR_ALREADY_EXISTS boost::winapi::ERROR_ALREADY_EXISTS_
50#define BOOST_ERROR_NOT_SUPPORTED boost::winapi::ERROR_NOT_SUPPORTED_
51
52#endif
53
54// error handling helpers ----------------------------------------------------------//
55
56// Implemented in exception.cpp
57void emit_error(err_t error_num, system::error_code* ec, const char* message);
58void emit_error(err_t error_num, const path& p, system::error_code* ec, const char* message);
59void emit_error(err_t error_num, const path& p1, const path& p2, system::error_code* ec, const char* message);
60
61inline bool error(err_t error_num, system::error_code* ec, const char* message)
62{
63 if (BOOST_LIKELY(!error_num))
64 {
65 if (ec)
66 ec->clear();
67 return false;
68 }
69 else
70 { // error
71 filesystem::emit_error(error_num, ec, message);
72 return true;
73 }
74}
75
76inline bool error(err_t error_num, const path& p, system::error_code* ec, const char* message)
77{
78 if (BOOST_LIKELY(!error_num))
79 {
80 if (ec)
81 ec->clear();
82 return false;
83 }
84 else
85 { // error
86 filesystem::emit_error(error_num, p, ec, message);
87 return true;
88 }
89}
90
91inline bool error(err_t error_num, const path& p1, const path& p2, system::error_code* ec, const char* message)
92{
93 if (BOOST_LIKELY(!error_num))
94 {
95 if (ec)
96 ec->clear();
97 return false;
98 }
99 else
100 { // error
101 filesystem::emit_error(error_num, p1, p2, ec, message);
102 return true;
103 }
104}
105
106} // namespace filesystem
107} // namespace boost
108
109#endif // BOOST_FILESYSTEM3_SRC_ERROR_HANDLING_HPP_