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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 | 39 |
40 File::~File() { | 40 File::~File() { |
41 Close(); | 41 Close(); |
42 delete handle_; | 42 delete handle_; |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 void File::Close() { | 46 void File::Close() { |
47 ASSERT(handle_->fd() >= 0); | 47 ASSERT(handle_->fd() >= 0); |
48 if (handle_->fd() == _fileno(stdout)) { | 48 if (handle_->fd() == _fileno(stdout) || handle_->fd() == _fileno(stderr)) { |
49 int fd = _open("NUL", _O_WRONLY); | 49 int fd = _open("NUL", _O_WRONLY); |
50 ASSERT(fd >= 0); | 50 ASSERT(fd >= 0); |
51 _dup2(fd, handle_->fd()); | 51 _dup2(fd, handle_->fd()); |
52 close(fd); | 52 close(fd); |
53 } else { | 53 } else { |
54 int err = close(handle_->fd()); | 54 int err = close(handle_->fd()); |
55 if (err != 0) { | 55 if (err != 0) { |
56 Log::PrintErr("%s\n", strerror(errno)); | 56 Log::PrintErr("%s\n", strerror(errno)); |
57 } | 57 } |
58 } | 58 } |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 return kIdentical; | 684 return kIdentical; |
685 } else { | 685 } else { |
686 return kDifferent; | 686 return kDifferent; |
687 } | 687 } |
688 } | 688 } |
689 | 689 |
690 } // namespace bin | 690 } // namespace bin |
691 } // namespace dart | 691 } // namespace dart |
692 | 692 |
693 #endif // defined(TARGET_OS_WINDOWS) | 693 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |