Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include <errno.h> | 5 #include <errno.h> |
| 6 | 6 |
| 7 #include "bin/log.h" | |
| 8 #include "bin/platform.h" | |
|
Ivan Posva
2012/11/15 07:43:17
Where does the need arise for platform.h?
gram
2012/11/15 21:16:50
Removed
| |
| 7 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 8 | 10 |
| 9 static void FormatMessageIntoBuffer(DWORD code, | 11 static void FormatMessageIntoBuffer(DWORD code, |
| 10 char* buffer, | 12 char* buffer, |
| 11 int buffer_length) { | 13 int buffer_length) { |
| 12 DWORD message_size = | 14 DWORD message_size = |
| 13 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | 15 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 14 NULL, | 16 NULL, |
| 15 code, | 17 code, |
| 16 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | 18 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 17 buffer, | 19 buffer, |
| 18 buffer_length, | 20 buffer_length, |
| 19 NULL); | 21 NULL); |
| 20 if (message_size == 0) { | 22 if (message_size == 0) { |
| 21 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { | 23 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { |
| 22 fprintf(stderr, "FormatMessage failed %d\n", GetLastError()); | 24 Log::PrintErr("FormatMessage failed %d\n", GetLastError()); |
| 23 } | 25 } |
| 24 snprintf(buffer, buffer_length, "OS Error %d", code); | 26 snprintf(buffer, buffer_length, "OS Error %d", code); |
| 25 } | 27 } |
| 26 buffer[buffer_length - 1] = '\0'; | 28 buffer[buffer_length - 1] = '\0'; |
| 27 } | 29 } |
| 28 | 30 |
| 29 | 31 |
| 30 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { | 32 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { |
| 31 set_code(GetLastError()); | 33 set_code(GetLastError()); |
| 32 | 34 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 return ansi; | 74 return ansi; |
| 73 } | 75 } |
| 74 | 76 |
| 75 const char* StringUtils::Utf8ToSystemString(const char* utf8) { | 77 const char* StringUtils::Utf8ToSystemString(const char* utf8) { |
| 76 return const_cast<const char*>(Utf8ToSystemString(const_cast<char*>(utf8))); | 78 return const_cast<const char*>(Utf8ToSystemString(const_cast<char*>(utf8))); |
| 77 } | 79 } |
| 78 | 80 |
| 79 const char* StringUtils::SystemStringToUtf8(const char* str) { | 81 const char* StringUtils::SystemStringToUtf8(const char* str) { |
| 80 return const_cast<const char*>(Utf8ToSystemString(const_cast<char*>(str))); | 82 return const_cast<const char*>(Utf8ToSystemString(const_cast<char*>(str))); |
| 81 } | 83 } |
| OLD | NEW |