| 111 | #define WSD(name, fs) struct WindowsFileStream* name = (struct WindowsFileStream*)(fs)->mUser.data |
| 112 | |
| 113 | class WindowsErrorString |
| 114 | { |
| 115 | LPVOID lpMsgBuf; |
| 116 | char utf8[FS_MAX_PATH]; |
| 117 | |
| 118 | public: |
| 119 | WindowsErrorString() |
| 120 | { |
| 121 | DWORD error = GetLastError(); |
| 122 | |
| 123 | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, |
| 124 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); |
| 125 | |
| 126 | if (!WideCharToMultiByte(CP_UTF8, 0, (LPCWCH)lpMsgBuf, -1, utf8, sizeof utf8, NULL, NULL)) |
| 127 | { |
| 128 | snprintf(utf8, sizeof utf8, "0x%x", error); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | ~WindowsErrorString() |
| 133 | { |
| 134 | if (lpMsgBuf) |
| 135 | LocalFree(lpMsgBuf); |
| 136 | } |
| 137 | |
| 138 | const char* c_str() { return utf8; } |
| 139 | }; |
| 140 | |
| 141 | static inline FORGE_CONSTEXPR const char* fsFileModeToString(FileMode mode) |
| 142 | { |
no outgoing calls
no test coverage detected