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