| Index: runtime/bin/utils_win.cc
|
| diff --git a/runtime/bin/utils_win.cc b/runtime/bin/utils_win.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..29491cba5b4f33b42c8330f36a9d814f9578eb0e
|
| --- /dev/null
|
| +++ b/runtime/bin/utils_win.cc
|
| @@ -0,0 +1,31 @@
|
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +#include <errno.h>
|
| +
|
| +#include "bin/utils.h"
|
| +
|
| +OSError::OSError() : code_(0), message_(NULL) {
|
| + set_code(GetLastError());
|
| +
|
| + static const int kMaxMessageLength = 256;
|
| + char message[kMaxMessageLength];
|
| + DWORD message_size =
|
| + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
| + NULL,
|
| + code_,
|
| + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
| + message,
|
| + kMaxMessageLength,
|
| + NULL);
|
| + if (message_size == 0) {
|
| + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
| + fprintf(stderr, "FormatMessage failed %d\n", GetLastError());
|
| + }
|
| + snprintf(message, kMaxMessageLength, "OS Error %d", code_);
|
| + }
|
| + message[kMaxMessageLength - 1] = '\0';
|
| +
|
| + SetMessage(message);
|
| +}
|
|
|