diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2017-04-16 11:44:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-16 11:44:08 +0200 |
| commit | b6433b2ae82a7c598a2e06dc987dc270879c891a (patch) | |
| tree | e50862c8c76048e99e1b3aaf809f2a23f945c260 /Source/Core/Common/CommonFuncs.cpp | |
| parent | a389ae0711142d8c5c996fda3d1e6c5731d71de3 (diff) | |
| parent | 2f9df072d6f64a09394bbbe9508d6d6fbcc8e1b5 (diff) | |
Merge pull request #5266 from JosJuice/misc
Rename Misc.cpp to CommonFuncs.cpp
Diffstat (limited to 'Source/Core/Common/CommonFuncs.cpp')
| -rw-r--r-- | Source/Core/Common/CommonFuncs.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/Core/Common/CommonFuncs.cpp b/Source/Core/Common/CommonFuncs.cpp new file mode 100644 index 0000000000..69ff018471 --- /dev/null +++ b/Source/Core/Common/CommonFuncs.cpp @@ -0,0 +1,33 @@ +// Copyright 2009 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include <cstddef> +#include <cstring> +#include <errno.h> + +#include "Common/CommonFuncs.h" + +#ifdef _WIN32 +#include <windows.h> +#endif + +// Generic function to get last error message. +// Call directly after the command or use the error num. +// This function might change the error code. +std::string GetLastErrorMsg() +{ + const size_t buff_size = 256; + char err_str[buff_size]; + +#ifdef _WIN32 + FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_str, buff_size, nullptr); +#else + // Thread safe (XSI-compliant) + if (strerror_r(errno, err_str, buff_size)) + return ""; +#endif + + return std::string(err_str); +} |
