diff options
Diffstat (limited to 'src/common/misc.cpp')
| -rw-r--r-- | src/common/misc.cpp | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/src/common/misc.cpp b/src/common/misc.cpp deleted file mode 100644 index 495385b9e..000000000 --- a/src/common/misc.cpp +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstddef> | ||
| 6 | #ifdef _WIN32 | ||
| 7 | #include <windows.h> | ||
| 8 | #else | ||
| 9 | #include <cerrno> | ||
| 10 | #include <cstring> | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #include "common/common_funcs.h" | ||
| 14 | |||
| 15 | std::string NativeErrorToString(int e) { | ||
| 16 | #ifdef _WIN32 | ||
| 17 | LPSTR err_str; | ||
| 18 | |||
| 19 | DWORD res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | | ||
| 20 | FORMAT_MESSAGE_IGNORE_INSERTS, | ||
| 21 | nullptr, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||
| 22 | reinterpret_cast<LPSTR>(&err_str), 1, nullptr); | ||
| 23 | if (!res) { | ||
| 24 | return "(FormatMessageA failed to format error)"; | ||
| 25 | } | ||
| 26 | std::string ret(err_str); | ||
| 27 | LocalFree(err_str); | ||
| 28 | return ret; | ||
| 29 | #else | ||
| 30 | char err_str[255]; | ||
| 31 | #if defined(__GLIBC__) && (_GNU_SOURCE || (_POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600)) | ||
| 32 | // Thread safe (GNU-specific) | ||
| 33 | const char* str = strerror_r(e, err_str, sizeof(err_str)); | ||
| 34 | return std::string(str); | ||
| 35 | #else | ||
| 36 | // Thread safe (XSI-compliant) | ||
| 37 | int second_err = strerror_r(e, err_str, sizeof(err_str)); | ||
| 38 | if (second_err != 0) { | ||
| 39 | return "(strerror_r failed to format error)"; | ||
| 40 | } | ||
| 41 | return std::string(err_str); | ||
| 42 | #endif // GLIBC etc. | ||
| 43 | #endif // _WIN32 | ||
| 44 | } | ||
| 45 | |||
| 46 | std::string GetLastErrorMsg() { | ||
| 47 | #ifdef _WIN32 | ||
| 48 | return NativeErrorToString(GetLastError()); | ||
| 49 | #else | ||
| 50 | return NativeErrorToString(errno); | ||
| 51 | #endif | ||
| 52 | } | ||