| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include "bin/file.h" | 8 #include "bin/file.h" |
| 9 | 9 |
| 10 #include <fcntl.h> // NOLINT | 10 #include <fcntl.h> // NOLINT |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 void set_fd(int fd) { fd_ = fd; } | 31 void set_fd(int fd) { fd_ = fd; } |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 int fd_; | 34 int fd_; |
| 35 | 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(FileHandle); | 36 DISALLOW_COPY_AND_ASSIGN(FileHandle); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 | 39 |
| 40 File::~File() { | 40 File::~File() { |
| 41 Close(); | 41 if (!IsClosed()) { |
| 42 Close(); |
| 43 } |
| 42 delete handle_; | 44 delete handle_; |
| 43 } | 45 } |
| 44 | 46 |
| 45 | 47 |
| 46 void File::Close() { | 48 void File::Close() { |
| 47 ASSERT(handle_->fd() >= 0); | 49 ASSERT(handle_->fd() >= 0); |
| 48 if ((handle_->fd() == _fileno(stdout)) || | 50 if ((handle_->fd() == _fileno(stdout)) || |
| 49 (handle_->fd() == _fileno(stderr))) { | 51 (handle_->fd() == _fileno(stderr))) { |
| 50 int fd = _open("NUL", _O_WRONLY); | 52 int fd = _open("NUL", _O_WRONLY); |
| 51 ASSERT(fd >= 0); | 53 ASSERT(fd >= 0); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 return kIdentical; | 687 return kIdentical; |
| 686 } else { | 688 } else { |
| 687 return kDifferent; | 689 return kDifferent; |
| 688 } | 690 } |
| 689 } | 691 } |
| 690 | 692 |
| 691 } // namespace bin | 693 } // namespace bin |
| 692 } // namespace dart | 694 } // namespace dart |
| 693 | 695 |
| 694 #endif // defined(TARGET_OS_WINDOWS) | 696 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |