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_SYSTEM_WINDOWS_ERROR_HPP 11 #define BOOST_SYSTEM_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 22 //// Neither MinGW or Cygwin versions of winerror.h work if used alone, so on 23 //// either of those platforms include the full windows.h 24 // 25 //#if defined(__MINGW32__) || defined(__CYGWIN__) 26 //#include <windows.h> 27 //#else 28 //#include <winerror.h> 29 //#endif 30 31 #include <boost/winapi/error_codes.hpp> 32 33 namespace boost 34 { 35 namespace system 36 { 37 38 // Microsoft Windows ---------------------------------------------------// 39 40 // To construct an error_code after a API error: 41 // 42 // error_code( ::GetLastError(), system_category() ) 43 44 namespace windows_error 45 { 46 enum windows_error_code 47 { 48 success = 0, 49 // These names and values are based on Windows winerror.h 50 invalid_function = boost::winapi::ERROR_INVALID_FUNCTION_, 51 file_not_found = boost::winapi::ERROR_FILE_NOT_FOUND_, 52 path_not_found = boost::winapi::ERROR_PATH_NOT_FOUND_, 53 too_many_open_files = boost::winapi::ERROR_TOO_MANY_OPEN_FILES_, 54 access_denied = boost::winapi::ERROR_ACCESS_DENIED_, 55 invalid_handle = boost::winapi::ERROR_INVALID_HANDLE_, 56 arena_trashed = boost::winapi::ERROR_ARENA_TRASHED_, 57 not_enough_memory = boost::winapi::ERROR_NOT_ENOUGH_MEMORY_, 58 invalid_block = boost::winapi::ERROR_INVALID_BLOCK_, 59 bad_environment = boost::winapi::ERROR_BAD_ENVIRONMENT_, 60 bad_format = boost::winapi::ERROR_BAD_FORMAT_, 61 invalid_access = boost::winapi::ERROR_INVALID_ACCESS_, 62 outofmemory = boost::winapi::ERROR_OUTOFMEMORY_, 63 invalid_drive = boost::winapi::ERROR_INVALID_DRIVE_, 64 current_directory = boost::winapi::ERROR_CURRENT_DIRECTORY_, 65 not_same_device = boost::winapi::ERROR_NOT_SAME_DEVICE_, 66 no_more_files = boost::winapi::ERROR_NO_MORE_FILES_, 67 write_protect = boost::winapi::ERROR_WRITE_PROTECT_, 68 bad_unit = boost::winapi::ERROR_BAD_UNIT_, 69 not_ready = boost::winapi::ERROR_NOT_READY_, 70 bad_command = boost::winapi::ERROR_BAD_COMMAND_, 71 crc = boost::winapi::ERROR_CRC_, 72 bad_length = boost::winapi::ERROR_BAD_LENGTH_, 73 seek = boost::winapi::ERROR_SEEK_, 74 not_dos_disk = boost::winapi::ERROR_NOT_DOS_DISK_, 75 sector_not_found = boost::winapi::ERROR_SECTOR_NOT_FOUND_, 76 out_of_paper = boost::winapi::ERROR_OUT_OF_PAPER_, 77 write_fault = boost::winapi::ERROR_WRITE_FAULT_, 78 read_fault = boost::winapi::ERROR_READ_FAULT_, 79 gen_failure = boost::winapi::ERROR_GEN_FAILURE_, 80 sharing_violation = boost::winapi::ERROR_SHARING_VIOLATION_, 81 lock_violation = boost::winapi::ERROR_LOCK_VIOLATION_, 82 wrong_disk = boost::winapi::ERROR_WRONG_DISK_, 83 sharing_buffer_exceeded = boost::winapi::ERROR_SHARING_BUFFER_EXCEEDED_, 84 handle_eof = boost::winapi::ERROR_HANDLE_EOF_, 85 handle_disk_full= boost::winapi::ERROR_HANDLE_DISK_FULL_, 86 rem_not_list = boost::winapi::ERROR_REM_NOT_LIST_, 87 dup_name = boost::winapi::ERROR_DUP_NAME_, 88 bad_net_path = boost::winapi::ERROR_BAD_NETPATH_, 89 network_busy = boost::winapi::ERROR_NETWORK_BUSY_, 90 // ... 91 file_exists = boost::winapi::ERROR_FILE_EXISTS_, 92 cannot_make = boost::winapi::ERROR_CANNOT_MAKE_, 93 // ... 94 broken_pipe = boost::winapi::ERROR_BROKEN_PIPE_, 95 open_failed = boost::winapi::ERROR_OPEN_FAILED_, 96 buffer_overflow = boost::winapi::ERROR_BUFFER_OVERFLOW_, 97 disk_full= boost::winapi::ERROR_DISK_FULL_, 98 // ... 99 lock_failed = boost::winapi::ERROR_LOCK_FAILED_, 100 busy = boost::winapi::ERROR_BUSY_, 101 cancel_violation = boost::winapi::ERROR_CANCEL_VIOLATION_, 102 already_exists = boost::winapi::ERROR_ALREADY_EXISTS_ 103 // ... 104 105 // TODO: add more Windows errors 106 }; 107 108 } // namespace windows 109 110 # ifdef BOOST_SYSTEM_ENABLE_DEPRECATED 111 namespace windows = windows_error; 112 # endif 113 114 template<> struct is_error_code_enum<windows_error::windows_error_code> 115 { static const bool value = true; }; 116 117 namespace windows_error 118 { make_error_code(windows_error_code e)119 inline error_code make_error_code( windows_error_code e ) 120 { return error_code( e, system_category() ); } 121 } 122 123 } // namespace system 124 } // namespace boost 125 126 #endif // BOOST_WINDOWS_API 127 128 #endif // BOOST_SYSTEM_WINDOWS_ERROR_HPP 129