OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #ifndef BIN_UTILS_H_ |
| 6 #define BIN_UTILS_H_ |
| 7 |
| 8 #include <stdlib.h> |
| 9 #include <string.h> |
| 10 |
| 11 #include "include/dart_api.h" |
| 12 #include "platform/globals.h" |
| 13 |
| 14 class OSError { |
| 15 public: |
| 16 OSError(); |
| 17 OSError(int code, char* message) { |
| 18 code_ = code; |
| 19 SetMessage(message); |
| 20 } |
| 21 virtual ~OSError() { free(message_); } |
| 22 |
| 23 int code() { return code_; } |
| 24 void set_code(int code) { code_ = code; } |
| 25 char* message() { return message_; } |
| 26 void SetMessage(char* message) { |
| 27 free(message_); |
| 28 if (message == NULL) { |
| 29 message_ = NULL; |
| 30 } else { |
| 31 message_ = strdup(message); |
| 32 } |
| 33 } |
| 34 |
| 35 private: |
| 36 int code_; |
| 37 char* message_; |
| 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(OSError); |
| 40 }; |
| 41 |
| 42 #endif // BIN_UTILS_H_ |
OLD | NEW |