Chris@16
|
1 // boost/system/windows_error.hpp ------------------------------------------//
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright Beman Dawes 2007
|
Chris@16
|
4
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7
|
Chris@16
|
8 // See library home page at http://www.boost.org/libs/system
|
Chris@16
|
9
|
Chris@16
|
10 #ifndef BOOST_WINDOWS_ERROR_HPP
|
Chris@16
|
11 #define BOOST_WINDOWS_ERROR_HPP
|
Chris@16
|
12
|
Chris@16
|
13 // This header is effectively empty for compiles on operating systems where
|
Chris@16
|
14 // it is not applicable.
|
Chris@16
|
15
|
Chris@16
|
16 #include <boost/system/config.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 #ifdef BOOST_WINDOWS_API
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/system/error_code.hpp>
|
Chris@101
|
21
|
Chris@101
|
22 // Neither MinGW or Cygwin versions of winerror.h work if used alone, so on
|
Chris@101
|
23 // either of those platforms include the full windows.h
|
Chris@101
|
24
|
Chris@101
|
25 #if defined(__MINGW32__) || defined(__CYGWIN__)
|
Chris@101
|
26 #include <windows.h>
|
Chris@101
|
27 #else
|
Chris@16
|
28 #include <winerror.h>
|
Chris@101
|
29 #endif
|
Chris@16
|
30
|
Chris@16
|
31 namespace boost
|
Chris@16
|
32 {
|
Chris@16
|
33 namespace system
|
Chris@16
|
34 {
|
Chris@16
|
35
|
Chris@16
|
36 // Microsoft Windows ---------------------------------------------------//
|
Chris@16
|
37
|
Chris@16
|
38 // To construct an error_code after a API error:
|
Chris@16
|
39 //
|
Chris@16
|
40 // error_code( ::GetLastError(), system_category() )
|
Chris@16
|
41
|
Chris@16
|
42 namespace windows_error
|
Chris@16
|
43 {
|
Chris@16
|
44 enum windows_error_code
|
Chris@16
|
45 {
|
Chris@16
|
46 success = 0,
|
Chris@16
|
47 // These names and values are based on Windows winerror.h
|
Chris@16
|
48 invalid_function = ERROR_INVALID_FUNCTION,
|
Chris@16
|
49 file_not_found = ERROR_FILE_NOT_FOUND,
|
Chris@16
|
50 path_not_found = ERROR_PATH_NOT_FOUND,
|
Chris@16
|
51 too_many_open_files = ERROR_TOO_MANY_OPEN_FILES,
|
Chris@16
|
52 access_denied = ERROR_ACCESS_DENIED,
|
Chris@16
|
53 invalid_handle = ERROR_INVALID_HANDLE,
|
Chris@16
|
54 arena_trashed = ERROR_ARENA_TRASHED,
|
Chris@16
|
55 not_enough_memory = ERROR_NOT_ENOUGH_MEMORY,
|
Chris@16
|
56 invalid_block = ERROR_INVALID_BLOCK,
|
Chris@16
|
57 bad_environment = ERROR_BAD_ENVIRONMENT,
|
Chris@16
|
58 bad_format = ERROR_BAD_FORMAT,
|
Chris@16
|
59 invalid_access = ERROR_INVALID_ACCESS,
|
Chris@16
|
60 outofmemory = ERROR_OUTOFMEMORY,
|
Chris@16
|
61 invalid_drive = ERROR_INVALID_DRIVE,
|
Chris@16
|
62 current_directory = ERROR_CURRENT_DIRECTORY,
|
Chris@16
|
63 not_same_device = ERROR_NOT_SAME_DEVICE,
|
Chris@16
|
64 no_more_files = ERROR_NO_MORE_FILES,
|
Chris@16
|
65 write_protect = ERROR_WRITE_PROTECT,
|
Chris@16
|
66 bad_unit = ERROR_BAD_UNIT,
|
Chris@16
|
67 not_ready = ERROR_NOT_READY,
|
Chris@16
|
68 bad_command = ERROR_BAD_COMMAND,
|
Chris@16
|
69 crc = ERROR_CRC,
|
Chris@16
|
70 bad_length = ERROR_BAD_LENGTH,
|
Chris@16
|
71 seek = ERROR_SEEK,
|
Chris@16
|
72 not_dos_disk = ERROR_NOT_DOS_DISK,
|
Chris@16
|
73 sector_not_found = ERROR_SECTOR_NOT_FOUND,
|
Chris@16
|
74 out_of_paper = ERROR_OUT_OF_PAPER,
|
Chris@16
|
75 write_fault = ERROR_WRITE_FAULT,
|
Chris@16
|
76 read_fault = ERROR_READ_FAULT,
|
Chris@16
|
77 gen_failure = ERROR_GEN_FAILURE,
|
Chris@16
|
78 sharing_violation = ERROR_SHARING_VIOLATION,
|
Chris@16
|
79 lock_violation = ERROR_LOCK_VIOLATION,
|
Chris@16
|
80 wrong_disk = ERROR_WRONG_DISK,
|
Chris@16
|
81 sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED,
|
Chris@16
|
82 handle_eof = ERROR_HANDLE_EOF,
|
Chris@16
|
83 handle_disk_full= ERROR_HANDLE_DISK_FULL,
|
Chris@16
|
84 rem_not_list = ERROR_REM_NOT_LIST,
|
Chris@16
|
85 dup_name = ERROR_DUP_NAME,
|
Chris@16
|
86 bad_net_path = ERROR_BAD_NETPATH,
|
Chris@16
|
87 network_busy = ERROR_NETWORK_BUSY,
|
Chris@16
|
88 // ...
|
Chris@16
|
89 file_exists = ERROR_FILE_EXISTS,
|
Chris@16
|
90 cannot_make = ERROR_CANNOT_MAKE,
|
Chris@16
|
91 // ...
|
Chris@16
|
92 broken_pipe = ERROR_BROKEN_PIPE,
|
Chris@16
|
93 open_failed = ERROR_OPEN_FAILED,
|
Chris@16
|
94 buffer_overflow = ERROR_BUFFER_OVERFLOW,
|
Chris@16
|
95 disk_full= ERROR_DISK_FULL,
|
Chris@16
|
96 // ...
|
Chris@16
|
97 lock_failed = ERROR_LOCK_FAILED,
|
Chris@16
|
98 busy = ERROR_BUSY,
|
Chris@16
|
99 cancel_violation = ERROR_CANCEL_VIOLATION,
|
Chris@16
|
100 already_exists = ERROR_ALREADY_EXISTS
|
Chris@16
|
101 // ...
|
Chris@16
|
102
|
Chris@16
|
103 // TODO: add more Windows errors
|
Chris@16
|
104 };
|
Chris@16
|
105
|
Chris@16
|
106 } // namespace windows
|
Chris@16
|
107
|
Chris@16
|
108 # ifndef BOOST_SYSTEM_NO_DEPRECATED
|
Chris@16
|
109 namespace windows = windows_error;
|
Chris@16
|
110 # endif
|
Chris@16
|
111
|
Chris@16
|
112 template<> struct is_error_code_enum<windows_error::windows_error_code>
|
Chris@16
|
113 { static const bool value = true; };
|
Chris@16
|
114
|
Chris@16
|
115 namespace windows_error
|
Chris@16
|
116 {
|
Chris@16
|
117 inline error_code make_error_code( windows_error_code e )
|
Chris@16
|
118 { return error_code( e, system_category() ); }
|
Chris@16
|
119 }
|
Chris@16
|
120
|
Chris@16
|
121 } // namespace system
|
Chris@16
|
122 } // namespace boost
|
Chris@16
|
123
|
Chris@16
|
124 #endif // BOOST_WINDOWS_API
|
Chris@16
|
125
|
Chris@16
|
126 #endif // BOOST_WINDOWS_ERROR_HPP
|