MCPcopy Create free account
hub / github.com/ConfettiFX/The-Forge / WindowsErrorString

Class WindowsErrorString

Common_3/OS/Windows/WindowsFileSystem.cpp:113–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111#define WSD(name, fs) struct WindowsFileStream* name = (struct WindowsFileStream*)(fs)->mUser.data
112
113class WindowsErrorString
114{
115 LPVOID lpMsgBuf;
116 char utf8[FS_MAX_PATH];
117
118public:
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
141static inline FORGE_CONSTEXPR const char* fsFileModeToString(FileMode mode)
142{

Callers 2

ioWindowsFsGetSizeFunction · 0.85
ioWindowsFsCloseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected