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 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 namespace pdalboost 32 { 33 namespace system 34 { 35 36 // Microsoft Windows ---------------------------------------------------// 37 38 // To construct an error_code after a API error: 39 // 40 // error_code( ::GetLastError(), system_category() ) 41 42 namespace windows_error 43 { 44 enum windows_error_code 45 { 46 success = 0, 47 // These names and values are based on Windows winerror.h 48 invalid_function = ERROR_INVALID_FUNCTION, 49 file_not_found = ERROR_FILE_NOT_FOUND, 50 path_not_found = ERROR_PATH_NOT_FOUND, 51 too_many_open_files = ERROR_TOO_MANY_OPEN_FILES, 52 access_denied = ERROR_ACCESS_DENIED, 53 invalid_handle = ERROR_INVALID_HANDLE, 54 arena_trashed = ERROR_ARENA_TRASHED, 55 not_enough_memory = ERROR_NOT_ENOUGH_MEMORY, 56 invalid_block = ERROR_INVALID_BLOCK, 57 bad_environment = ERROR_BAD_ENVIRONMENT, 58 bad_format = ERROR_BAD_FORMAT, 59 invalid_access = ERROR_INVALID_ACCESS, 60 outofmemory = ERROR_OUTOFMEMORY, 61 invalid_drive = ERROR_INVALID_DRIVE, 62 current_directory = ERROR_CURRENT_DIRECTORY, 63 not_same_device = ERROR_NOT_SAME_DEVICE, 64 no_more_files = ERROR_NO_MORE_FILES, 65 write_protect = ERROR_WRITE_PROTECT, 66 bad_unit = ERROR_BAD_UNIT, 67 not_ready = ERROR_NOT_READY, 68 bad_command = ERROR_BAD_COMMAND, 69 crc = ERROR_CRC, 70 bad_length = ERROR_BAD_LENGTH, 71 seek = ERROR_SEEK, 72 not_dos_disk = ERROR_NOT_DOS_DISK, 73 sector_not_found = ERROR_SECTOR_NOT_FOUND, 74 out_of_paper = ERROR_OUT_OF_PAPER, 75 write_fault = ERROR_WRITE_FAULT, 76 read_fault = ERROR_READ_FAULT, 77 gen_failure = ERROR_GEN_FAILURE, 78 sharing_violation = ERROR_SHARING_VIOLATION, 79 lock_violation = ERROR_LOCK_VIOLATION, 80 wrong_disk = ERROR_WRONG_DISK, 81 sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED, 82 handle_eof = ERROR_HANDLE_EOF, 83 handle_disk_full= ERROR_HANDLE_DISK_FULL, 84 rem_not_list = ERROR_REM_NOT_LIST, 85 dup_name = ERROR_DUP_NAME, 86 bad_net_path = ERROR_BAD_NETPATH, 87 network_busy = ERROR_NETWORK_BUSY, 88 // ... 89 file_exists = ERROR_FILE_EXISTS, 90 cannot_make = ERROR_CANNOT_MAKE, 91 // ... 92 broken_pipe = ERROR_BROKEN_PIPE, 93 open_failed = ERROR_OPEN_FAILED, 94 buffer_overflow = ERROR_BUFFER_OVERFLOW, 95 disk_full= ERROR_DISK_FULL, 96 // ... 97 lock_failed = ERROR_LOCK_FAILED, 98 busy = ERROR_BUSY, 99 cancel_violation = ERROR_CANCEL_VIOLATION, 100 already_exists = ERROR_ALREADY_EXISTS 101 // ... 102 103 // TODO: add more Windows errors 104 }; 105 106 } // namespace windows 107 108 # ifndef BOOST_SYSTEM_NO_DEPRECATED 109 namespace windows = windows_error; 110 # endif 111 112 template<> struct is_error_code_enum<windows_error::windows_error_code> 113 { static const bool value = true; }; 114 115 namespace windows_error 116 { make_error_code(windows_error_code e)117 inline error_code make_error_code( windows_error_code e ) 118 { return error_code( e, system_category() ); } 119 } 120 121 } // namespace system 122 } // namespace pdalboost 123 124 #endif // BOOST_WINDOWS_API 125 126 #endif // BOOST_WINDOWS_ERROR_HPP 127