diff options
author | Chris Lattner <sabre@nondot.org> | 2006-07-07 17:13:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-07-07 17:13:10 +0000 |
commit | cc2fa54dfa5096772a2cdc3881e6f13791d41e2a (patch) | |
tree | c9fc94cdf9b4ff6eba5ee42b8ed0aa4e13b8cc59 /lib/System/Win32 | |
parent | adcbce0ad42a156ca0f9d9fc34c61a6d7c9277ac (diff) | |
download | external_llvm-cc2fa54dfa5096772a2cdc3881e6f13791d41e2a.zip external_llvm-cc2fa54dfa5096772a2cdc3881e6f13791d41e2a.tar.gz external_llvm-cc2fa54dfa5096772a2cdc3881e6f13791d41e2a.tar.bz2 |
Add a helper function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32')
-rw-r--r-- | lib/System/Win32/Win32.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/System/Win32/Win32.h b/lib/System/Win32/Win32.h index 7ed1047..d102991 100644 --- a/lib/System/Win32/Win32.h +++ b/lib/System/Win32/Win32.h @@ -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, |