2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-03-07 08:35:01 +00:00
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
2011-03-16 22:58:24 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#define __thread
|
|
|
|
#endif
|
|
|
|
|
2009-03-07 08:35:01 +00:00
|
|
|
// Generic function to get last error message.
|
|
|
|
// Call directly after the command or use the error num.
|
|
|
|
// This function might change the error code.
|
2011-03-16 21:08:20 +00:00
|
|
|
const char* GetLastErrorMsg()
|
2009-03-07 08:35:01 +00:00
|
|
|
{
|
2011-03-16 21:08:20 +00:00
|
|
|
static const size_t buff_size = 255;
|
|
|
|
|
2009-03-07 08:35:01 +00:00
|
|
|
#ifdef _WIN32
|
2011-03-16 21:08:20 +00:00
|
|
|
static __declspec(thread) char err_str[buff_size] = {};
|
|
|
|
|
2013-02-28 00:51:02 +00:00
|
|
|
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
|
2011-03-16 21:08:20 +00:00
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
err_str, buff_size, NULL);
|
2009-03-07 08:35:01 +00:00
|
|
|
#else
|
2011-03-16 21:08:20 +00:00
|
|
|
static __thread char err_str[buff_size] = {};
|
|
|
|
|
2009-03-07 08:35:01 +00:00
|
|
|
// Thread safe (XSI-compliant)
|
2011-03-16 21:08:20 +00:00
|
|
|
strerror_r(errno, err_str, buff_size);
|
2009-03-07 08:35:01 +00:00
|
|
|
#endif
|
2011-03-16 21:08:20 +00:00
|
|
|
|
|
|
|
return err_str;
|
2009-03-07 08:35:01 +00:00
|
|
|
}
|