Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/exception_io.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #pragma once | |
| 2 | |
| 3 | |
| 4 namespace foobar2000_io | |
| 5 { | |
| 6 //! Generic I/O error. Root class for I/O failure exception. See relevant default message for description of each derived exception class. | |
| 7 PFC_DECLARE_EXCEPTION(exception_io, pfc::exception, "I/O error"); | |
| 8 //! Object not found. | |
| 9 PFC_DECLARE_EXCEPTION(exception_io_not_found, exception_io, "Object not found"); | |
| 10 //! Access denied. \n | |
| 11 //! Special Windows note: this MAY be thrown instead of exception_io_sharing_violation by operations that rename/move files due to Win32 MoveFile() bugs. | |
| 12 PFC_DECLARE_EXCEPTION(exception_io_denied, exception_io, "Access denied"); | |
| 13 //! Access denied. | |
| 14 PFC_DECLARE_EXCEPTION(exception_io_denied_readonly, exception_io_denied, "File is read-only"); | |
| 15 //! Unsupported format or corrupted file (unexpected data encountered). | |
| 16 PFC_DECLARE_EXCEPTION(exception_io_data, exception_io, "Unsupported format or corrupted file"); | |
| 17 //! Unsupported format or corrupted file (truncation encountered). | |
| 18 PFC_DECLARE_EXCEPTION(exception_io_data_truncation, exception_io_data, "Unsupported format or corrupted file"); | |
| 19 //! Unsupported format (a subclass of "unsupported format or corrupted file" exception). | |
| 20 PFC_DECLARE_EXCEPTION(exception_io_unsupported_format, exception_io_data, "Unsupported file format"); | |
| 21 //! Decode error - subsong index out of expected range | |
| 22 PFC_DECLARE_EXCEPTION(exception_io_bad_subsong_index, exception_io_data, "Unexpected subsong index"); | |
| 23 //! Object is remote, while specific operation is supported only for local objects. | |
| 24 PFC_DECLARE_EXCEPTION(exception_io_object_is_remote, exception_io, "This operation is not supported on remote objects"); | |
| 25 //! Sharing violation. | |
| 26 PFC_DECLARE_EXCEPTION(exception_io_sharing_violation, exception_io, "File is already in use"); | |
| 27 //! Device full. | |
| 28 PFC_DECLARE_EXCEPTION(exception_io_device_full, exception_io, "Device full"); | |
| 29 //! Attempt to seek outside valid range. | |
| 30 PFC_DECLARE_EXCEPTION(exception_io_seek_out_of_range, exception_io, "Seek offset out of range"); | |
| 31 //! This operation requires a seekable object. | |
| 32 PFC_DECLARE_EXCEPTION(exception_io_object_not_seekable, exception_io, "Object is not seekable"); | |
| 33 //! This operation requires an object with known length. | |
| 34 PFC_DECLARE_EXCEPTION(exception_io_no_length, exception_io, "Length of object is unknown"); | |
| 35 //! Invalid path. | |
| 36 PFC_DECLARE_EXCEPTION(exception_io_no_handler_for_path, exception_io, "Invalid path"); | |
| 37 //! Object already exists. | |
| 38 PFC_DECLARE_EXCEPTION(exception_io_already_exists, exception_io, "Object already exists"); | |
| 39 //! Pipe error. | |
| 40 PFC_DECLARE_EXCEPTION(exception_io_no_data, exception_io, "The process receiving or sending data has terminated"); | |
| 41 //! Network not reachable. | |
| 42 PFC_DECLARE_EXCEPTION(exception_io_network_not_reachable, exception_io, "Network not reachable"); | |
| 43 //! Media is write protected. | |
| 44 PFC_DECLARE_EXCEPTION(exception_io_write_protected, exception_io_denied, "The media is write protected"); | |
| 45 //! File is corrupted. This indicates filesystem call failure, not actual invalid data being read by the app. | |
| 46 PFC_DECLARE_EXCEPTION(exception_io_file_corrupted, exception_io, "The file is corrupted"); | |
| 47 //! The disc required for requested operation is not available. | |
| 48 PFC_DECLARE_EXCEPTION(exception_io_disk_change, exception_io, "Disc not available"); | |
| 49 //! The directory is not empty. | |
| 50 PFC_DECLARE_EXCEPTION(exception_io_directory_not_empty, exception_io, "Directory not empty"); | |
| 51 //! A network connectivity error | |
| 52 PFC_DECLARE_EXCEPTION(exception_io_net, exception_io, "Network error"); | |
| 53 //! A network security error | |
| 54 PFC_DECLARE_EXCEPTION(exception_io_net_security, exception_io_net, "Network security error"); | |
| 55 //! A network connectivity error, specifically a DNS query failure | |
| 56 PFC_DECLARE_EXCEPTION(exception_io_dns, exception_io_net, "DNS error"); | |
| 57 //! The path does not point to a directory. | |
| 58 PFC_DECLARE_EXCEPTION(exception_io_not_directory, exception_io, "Not a directory"); | |
| 59 //! Functionality not supported by this device or file system. | |
| 60 PFC_DECLARE_EXCEPTION(exception_io_unsupported_feature, exception_io, "Unsupported feature"); | |
| 61 | |
| 62 #ifdef _WIN32 | |
| 63 PFC_NORETURN void exception_io_from_win32(DWORD p_code); | |
| 64 #define WIN32_IO_OP(X) {SetLastError(NO_ERROR); if (!(X)) exception_io_from_win32(GetLastError());} | |
| 65 | |
| 66 // SPECIAL WORKAROUND: throw "file is read-only" rather than "access denied" where appropriate | |
| 67 PFC_NORETURN void win32_file_write_failure(DWORD p_code, const char* path); | |
| 68 #else | |
| 69 | |
| 70 PFC_NORETURN void exception_io_from_nix(int code); | |
| 71 PFC_NORETURN void nix_io_op_fail(); | |
| 72 void nix_pre_io_op(); | |
| 73 #define NIX_IO_OP(X) { if (!(X)) nix_io_op_fail();} | |
| 74 | |
| 75 #endif | |
| 76 | |
| 77 } |
