Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: runtime/bin/platform_win.cc

Issue 8511001: Reapply directory error handling change. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cut down on includes in posix version. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/platform_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/platform_win.cc
diff --git a/runtime/bin/platform_win.cc b/runtime/bin/platform_win.cc
index 929ec875c733fed1be17e6b96350b27692bca6a1..f3ff633329fd1ac635a9b56c17251c46a2ac1c90 100644
--- a/runtime/bin/platform_win.cc
+++ b/runtime/bin/platform_win.cc
@@ -15,3 +15,33 @@ int Platform::NumberOfProcessors() {
const char* Platform::OperatingSystem() {
return "windows";
}
+
+
+char* Platform::StrError(int error_code) {
+ static const int kBufferSize = 1024;
+ char* error = static_cast<char*>(malloc(kBufferSize));
+ DWORD message_size =
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ error_code,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ error,
+ kBufferSize,
+ NULL);
+ if (message_size == 0) {
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ fprintf(stderr, "FormatMessage failed %d\n", GetLastError());
+ }
+ snprintf(error, kBufferSize, "OS Error %d", error_code);
+ }
+ // Strip out \r\n at the end of the generated message and ensure
+ // null termination.
+ if (message_size > 2 &&
+ error[message_size - 2] == '\r' &&
+ error[message_size - 1] == '\n') {
+ error[message_size - 2] = '\0';
+ } else {
+ error[kBufferSize - 1] = '\0';
+ }
+ return error;
+}
« no previous file with comments | « runtime/bin/platform_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698