mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-18 17:55:18 +00:00
Add a helper function
llvm-svn: 29049
This commit is contained in:
parent
832e60566f
commit
afbae9010f
@ -24,6 +24,16 @@
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
inline bool GetError(const std::string &Prefix, std::string *Dest) {
|
||||
if (Dest == 0) return;
|
||||
char *buffer = NULL;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
|
||||
*Dest = Prefix + buffer;
|
||||
LocalFree(buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void ThrowError(const std::string& msg) {
|
||||
char *buffer = NULL;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
|
Loading…
x
Reference in New Issue
Block a user