File indexing completed on 2025-01-30 10:00:56
0001 #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_CONDITION_WIN32_HPP_INCLUDED
0002 #define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_CONDITION_WIN32_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <boost/system/detail/errc.hpp>
0014 #include <boost/winapi/error_codes.hpp>
0015 #include <boost/config.hpp>
0016
0017
0018
0019 namespace boost
0020 {
0021
0022 namespace system
0023 {
0024
0025 namespace detail
0026 {
0027
0028 inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
0029 {
0030
0031
0032
0033
0034 #define BOOST_SYSTEM_FAILED(hr) ((hr) < 0)
0035 #define BOOST_SYSTEM_HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
0036 #define BOOST_SYSTEM_HRESULT_CODE(hr) ((hr) & 0xFFFF)
0037 #define BOOST_SYSTEM_FACILITY_WIN32 7
0038
0039 if( BOOST_SYSTEM_FAILED( ev ) && BOOST_SYSTEM_HRESULT_FACILITY( ev ) == BOOST_SYSTEM_FACILITY_WIN32 )
0040 {
0041 ev = BOOST_SYSTEM_HRESULT_CODE( ev );
0042 }
0043
0044 #undef BOOST_SYSTEM_FAILED
0045 #undef BOOST_SYSTEM_HRESULT_FACILITY
0046 #undef BOOST_SYSTEM_HRESULT_CODE
0047 #undef BOOST_SYSTEM_FACILITY_WIN32
0048
0049 using namespace boost::winapi;
0050 using namespace errc;
0051
0052
0053
0054
0055 switch ( ev )
0056 {
0057 case 0: return success;
0058
0059 case ERROR_ACCESS_DENIED_: return permission_denied;
0060 case ERROR_ALREADY_EXISTS_: return file_exists;
0061 case ERROR_BAD_NETPATH_: return no_such_file_or_directory;
0062 case ERROR_BAD_NET_NAME_: return no_such_file_or_directory;
0063 case ERROR_BAD_UNIT_: return no_such_device;
0064 case ERROR_BROKEN_PIPE_: return broken_pipe;
0065 case ERROR_BUFFER_OVERFLOW_: return filename_too_long;
0066 case ERROR_BUSY_: return device_or_resource_busy;
0067 case ERROR_BUSY_DRIVE_: return device_or_resource_busy;
0068 case ERROR_CANNOT_MAKE_: return permission_denied;
0069 case ERROR_CANTOPEN_: return io_error;
0070 case ERROR_CANTREAD_: return io_error;
0071 case ERROR_CANTWRITE_: return io_error;
0072 case ERROR_CONNECTION_ABORTED_: return connection_aborted;
0073 case ERROR_CURRENT_DIRECTORY_: return permission_denied;
0074 case ERROR_DEV_NOT_EXIST_: return no_such_device;
0075 case ERROR_DEVICE_IN_USE_: return device_or_resource_busy;
0076 case ERROR_DIR_NOT_EMPTY_: return directory_not_empty;
0077 case ERROR_DIRECTORY_: return invalid_argument;
0078 case ERROR_DISK_FULL_: return no_space_on_device;
0079 case ERROR_FILENAME_EXCED_RANGE_: return filename_too_long;
0080 case ERROR_FILE_EXISTS_: return file_exists;
0081 case ERROR_FILE_NOT_FOUND_: return no_such_file_or_directory;
0082 case ERROR_HANDLE_DISK_FULL_: return no_space_on_device;
0083 case ERROR_INVALID_ACCESS_: return permission_denied;
0084 case ERROR_INVALID_DRIVE_: return no_such_device;
0085 case ERROR_INVALID_FUNCTION_: return function_not_supported;
0086 case ERROR_INVALID_HANDLE_: return invalid_argument;
0087 case ERROR_INVALID_NAME_: return no_such_file_or_directory;
0088 case ERROR_INVALID_PARAMETER_: return invalid_argument;
0089 case ERROR_LOCK_VIOLATION_: return no_lock_available;
0090 case ERROR_LOCKED_: return no_lock_available;
0091 case ERROR_NEGATIVE_SEEK_: return invalid_argument;
0092 case ERROR_NOACCESS_: return permission_denied;
0093 case ERROR_NOT_ENOUGH_MEMORY_: return not_enough_memory;
0094 case ERROR_NOT_READY_: return resource_unavailable_try_again;
0095 case ERROR_NOT_SAME_DEVICE_: return cross_device_link;
0096 case ERROR_OPEN_FAILED_: return io_error;
0097 case ERROR_OPEN_FILES_: return device_or_resource_busy;
0098 case ERROR_OPERATION_ABORTED_: return operation_canceled;
0099 case ERROR_OUTOFMEMORY_: return not_enough_memory;
0100 case ERROR_PATH_NOT_FOUND_: return no_such_file_or_directory;
0101 case ERROR_READ_FAULT_: return io_error;
0102 case ERROR_REPARSE_TAG_INVALID_: return invalid_argument;
0103 case ERROR_RETRY_: return resource_unavailable_try_again;
0104 case ERROR_SEEK_: return io_error;
0105 case ERROR_SEM_TIMEOUT_: return timed_out;
0106 case ERROR_SHARING_VIOLATION_: return permission_denied;
0107 case ERROR_NOT_SUPPORTED_: return not_supported;
0108 case ERROR_TIMEOUT_: return timed_out;
0109 case ERROR_TOO_MANY_OPEN_FILES_: return too_many_files_open;
0110 case ERROR_WRITE_FAULT_: return io_error;
0111 case ERROR_WRITE_PROTECT_: return permission_denied;
0112
0113 case 258: return timed_out;
0114
0115 case WSAEACCES_: return permission_denied;
0116 case WSAEADDRINUSE_: return address_in_use;
0117 case WSAEADDRNOTAVAIL_: return address_not_available;
0118 case WSAEAFNOSUPPORT_: return address_family_not_supported;
0119 case WSAEALREADY_: return connection_already_in_progress;
0120 case WSAEBADF_: return bad_file_descriptor;
0121 case WSAECONNABORTED_: return connection_aborted;
0122 case WSAECONNREFUSED_: return connection_refused;
0123 case WSAECONNRESET_: return connection_reset;
0124 case WSAEDESTADDRREQ_: return destination_address_required;
0125 case WSAEFAULT_: return bad_address;
0126 case WSAEHOSTUNREACH_: return host_unreachable;
0127 case WSAEINPROGRESS_: return operation_in_progress;
0128 case WSAEINTR_: return interrupted;
0129 case WSAEINVAL_: return invalid_argument;
0130 case WSAEISCONN_: return already_connected;
0131 case WSAEMFILE_: return too_many_files_open;
0132 case WSAEMSGSIZE_: return message_size;
0133 case WSAENAMETOOLONG_: return filename_too_long;
0134 case WSAENETDOWN_: return network_down;
0135 case WSAENETRESET_: return network_reset;
0136 case WSAENETUNREACH_: return network_unreachable;
0137 case WSAENOBUFS_: return no_buffer_space;
0138 case WSAENOPROTOOPT_: return no_protocol_option;
0139 case WSAENOTCONN_: return not_connected;
0140 case WSAENOTSOCK_: return not_a_socket;
0141 case WSAEOPNOTSUPP_: return operation_not_supported;
0142 case WSAEPROTONOSUPPORT_: return protocol_not_supported;
0143 case WSAEPROTOTYPE_: return wrong_protocol_type;
0144 case WSAETIMEDOUT_: return timed_out;
0145 case WSAEWOULDBLOCK_: return operation_would_block;
0146
0147 default: return -1;
0148 }
0149 }
0150
0151 }
0152
0153 }
0154
0155 }
0156
0157 #endif