summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Win32/Win32.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-07 17:13:10 +0000
committerChris Lattner <sabre@nondot.org>2006-07-07 17:13:10 +0000
commit5df249dfeac20f97fa450b73767449fd7994b2f1 (patch)
tree1d0693d9e4298c0e96043c340a63e07c06e061f8 /llvm/lib/System/Win32/Win32.h
parent8c8858a6c45d192e8495a015eaaaea763897c5ec (diff)
downloadbcm5719-llvm-5df249dfeac20f97fa450b73767449fd7994b2f1.tar.gz
bcm5719-llvm-5df249dfeac20f97fa450b73767449fd7994b2f1.zip
Add a helper function
llvm-svn: 29049
Diffstat (limited to 'llvm/lib/System/Win32/Win32.h')
-rw-r--r--llvm/lib/System/Win32/Win32.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/System/Win32/Win32.h b/llvm/lib/System/Win32/Win32.h
index 7ed10471de1..d1029916605 100644
--- a/llvm/lib/System/Win32/Win32.h
+++ b/llvm/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,
OpenPOWER on IntegriCloud