windows_error.hpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // boost/system/windows_error.hpp ------------------------------------------//
  2. // Copyright Beman Dawes 2007
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See library home page at http://www.boost.org/libs/system
  6. #ifndef BOOST_SYSTEM_WINDOWS_ERROR_HPP
  7. #define BOOST_SYSTEM_WINDOWS_ERROR_HPP
  8. // This header is effectively empty for compiles on operating systems where
  9. // it is not applicable.
  10. #include <boost/system/config.hpp>
  11. #ifdef BOOST_WINDOWS_API
  12. #include <boost/system/error_code.hpp>
  13. #include <boost/winapi/error_codes.hpp>
  14. namespace boost
  15. {
  16. namespace system
  17. {
  18. // Microsoft Windows ---------------------------------------------------//
  19. // To construct an error_code after a API error:
  20. //
  21. // error_code( ::GetLastError(), system_category() )
  22. namespace windows_error
  23. {
  24. enum windows_error_code
  25. {
  26. success = 0,
  27. // These names and values are based on Windows winerror.h
  28. invalid_function = boost::winapi::ERROR_INVALID_FUNCTION_,
  29. file_not_found = boost::winapi::ERROR_FILE_NOT_FOUND_,
  30. path_not_found = boost::winapi::ERROR_PATH_NOT_FOUND_,
  31. too_many_open_files = boost::winapi::ERROR_TOO_MANY_OPEN_FILES_,
  32. access_denied = boost::winapi::ERROR_ACCESS_DENIED_,
  33. invalid_handle = boost::winapi::ERROR_INVALID_HANDLE_,
  34. arena_trashed = boost::winapi::ERROR_ARENA_TRASHED_,
  35. not_enough_memory = boost::winapi::ERROR_NOT_ENOUGH_MEMORY_,
  36. invalid_block = boost::winapi::ERROR_INVALID_BLOCK_,
  37. bad_environment = boost::winapi::ERROR_BAD_ENVIRONMENT_,
  38. bad_format = boost::winapi::ERROR_BAD_FORMAT_,
  39. invalid_access = boost::winapi::ERROR_INVALID_ACCESS_,
  40. outofmemory = boost::winapi::ERROR_OUTOFMEMORY_,
  41. invalid_drive = boost::winapi::ERROR_INVALID_DRIVE_,
  42. current_directory = boost::winapi::ERROR_CURRENT_DIRECTORY_,
  43. not_same_device = boost::winapi::ERROR_NOT_SAME_DEVICE_,
  44. no_more_files = boost::winapi::ERROR_NO_MORE_FILES_,
  45. write_protect = boost::winapi::ERROR_WRITE_PROTECT_,
  46. bad_unit = boost::winapi::ERROR_BAD_UNIT_,
  47. not_ready = boost::winapi::ERROR_NOT_READY_,
  48. bad_command = boost::winapi::ERROR_BAD_COMMAND_,
  49. crc = boost::winapi::ERROR_CRC_,
  50. bad_length = boost::winapi::ERROR_BAD_LENGTH_,
  51. seek = boost::winapi::ERROR_SEEK_,
  52. not_dos_disk = boost::winapi::ERROR_NOT_DOS_DISK_,
  53. sector_not_found = boost::winapi::ERROR_SECTOR_NOT_FOUND_,
  54. out_of_paper = boost::winapi::ERROR_OUT_OF_PAPER_,
  55. write_fault = boost::winapi::ERROR_WRITE_FAULT_,
  56. read_fault = boost::winapi::ERROR_READ_FAULT_,
  57. gen_failure = boost::winapi::ERROR_GEN_FAILURE_,
  58. sharing_violation = boost::winapi::ERROR_SHARING_VIOLATION_,
  59. lock_violation = boost::winapi::ERROR_LOCK_VIOLATION_,
  60. wrong_disk = boost::winapi::ERROR_WRONG_DISK_,
  61. sharing_buffer_exceeded = boost::winapi::ERROR_SHARING_BUFFER_EXCEEDED_,
  62. handle_eof = boost::winapi::ERROR_HANDLE_EOF_,
  63. handle_disk_full = boost::winapi::ERROR_HANDLE_DISK_FULL_,
  64. not_supported = boost::winapi::ERROR_NOT_SUPPORTED_,
  65. rem_not_list = boost::winapi::ERROR_REM_NOT_LIST_,
  66. dup_name = boost::winapi::ERROR_DUP_NAME_,
  67. bad_net_path = boost::winapi::ERROR_BAD_NETPATH_,
  68. network_busy = boost::winapi::ERROR_NETWORK_BUSY_,
  69. // ...
  70. file_exists = boost::winapi::ERROR_FILE_EXISTS_,
  71. cannot_make = boost::winapi::ERROR_CANNOT_MAKE_,
  72. // ...
  73. broken_pipe = boost::winapi::ERROR_BROKEN_PIPE_,
  74. open_failed = boost::winapi::ERROR_OPEN_FAILED_,
  75. buffer_overflow = boost::winapi::ERROR_BUFFER_OVERFLOW_,
  76. disk_full = boost::winapi::ERROR_DISK_FULL_,
  77. // ...
  78. lock_failed = boost::winapi::ERROR_LOCK_FAILED_,
  79. busy = boost::winapi::ERROR_BUSY_,
  80. cancel_violation = boost::winapi::ERROR_CANCEL_VIOLATION_,
  81. already_exists = boost::winapi::ERROR_ALREADY_EXISTS_
  82. // ...
  83. // TODO: add more Windows errors
  84. };
  85. } // namespace windows
  86. # ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
  87. namespace windows = windows_error;
  88. # endif
  89. template<> struct is_error_code_enum<windows_error::windows_error_code>
  90. { static const bool value = true; };
  91. namespace windows_error
  92. {
  93. inline error_code make_error_code( windows_error_code e )
  94. { return error_code( e, system_category() ); }
  95. }
  96. } // namespace system
  97. } // namespace boost
  98. #endif // BOOST_WINDOWS_API
  99. #endif // BOOST_SYSTEM_WINDOWS_ERROR_HPP