mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-28 23:38:49 +00:00
Rename Misc.cpp to CommonFuncs.cpp
Because its only function is declared in CommonFuncs.h.
This commit is contained in:
parent
722aca0830
commit
2f9df072d6
5 changed files with 3 additions and 4 deletions
33
Source/Core/Common/CommonFuncs.cpp
Normal file
33
Source/Core/Common/CommonFuncs.cpp
Normal file
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue