]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/windows/systemerror.cpp
Move most platform-specific code into overlay directories
[libs/core.git] / source / core / windows / systemerror.cpp
diff --git a/source/core/windows/systemerror.cpp b/source/core/windows/systemerror.cpp
new file mode 100644 (file)
index 0000000..98eb9ed
--- /dev/null
@@ -0,0 +1,20 @@
+#include <windows.h>
+#include <msp/strings/lexicalcast.h>
+#include "systemerror.h"
+
+using namespace std;
+
+namespace Msp {
+string system_error::get_message(int c)
+{
+       if(c==-1)
+               c = GetLastError();
+
+       char msg[1024];
+       if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, c, 0, msg, sizeof(msg), 0))
+               return msg;
+       else
+               return lexical_cast<string>(c, Fmt().hex());
+}
+
+} // namespace Msp