| 42 | |
| 43 | namespace { |
| 44 | std::string get_error() |
| 45 | { |
| 46 | #ifdef WIN32 |
| 47 | DWORD error = GetLastError(); |
| 48 | LPSTR buf = NULL; |
| 49 | DWORD len = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 50 | NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL); |
| 51 | if (len > 0) { |
| 52 | std::string message{ buf }; |
| 53 | LocalFree(buf); |
| 54 | return message; |
| 55 | } |
| 56 | std::ostringstream b{}; |
| 57 | b << "unknown error " << error; |
| 58 | return b.str(); |
| 59 | #else |
| 60 | char* error = dlerror(); |
| 61 | if (error) |
| 62 | return std::string{ error }; |
| 63 | return std::string{}; |
| 64 | #endif |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | DFLibrary * OpenPlugin (std::filesystem::path filename) |
no test coverage detected