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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 21 matching lines...) Expand all Loading... |
32 void set_fd(int fd) { fd_ = fd; } | 32 void set_fd(int fd) { fd_ = fd; } |
33 | 33 |
34 private: | 34 private: |
35 int fd_; | 35 int fd_; |
36 | 36 |
37 DISALLOW_COPY_AND_ASSIGN(FileHandle); | 37 DISALLOW_COPY_AND_ASSIGN(FileHandle); |
38 }; | 38 }; |
39 | 39 |
40 | 40 |
41 File::~File() { | 41 File::~File() { |
42 if (!IsClosed()) { | 42 if (!IsClosed() && |
| 43 handle_->fd() != STDOUT_FILENO && handle_->fd() != STDERR_FILENO) { |
43 Close(); | 44 Close(); |
44 } | 45 } |
45 delete handle_; | 46 delete handle_; |
46 } | 47 } |
47 | 48 |
48 | 49 |
49 void File::Close() { | 50 void File::Close() { |
50 ASSERT(handle_->fd() >= 0); | 51 ASSERT(handle_->fd() >= 0); |
51 if (handle_->fd() == STDOUT_FILENO) { | 52 if (handle_->fd() == STDOUT_FILENO) { |
52 // If stdout, redirect fd to /dev/null. | 53 // If stdout, redirect fd to /dev/null. |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 return ((file_1_info.st_ino == file_2_info.st_ino) && | 519 return ((file_1_info.st_ino == file_2_info.st_ino) && |
519 (file_1_info.st_dev == file_2_info.st_dev)) ? | 520 (file_1_info.st_dev == file_2_info.st_dev)) ? |
520 File::kIdentical : | 521 File::kIdentical : |
521 File::kDifferent; | 522 File::kDifferent; |
522 } | 523 } |
523 | 524 |
524 } // namespace bin | 525 } // namespace bin |
525 } // namespace dart | 526 } // namespace dart |
526 | 527 |
527 #endif // defined(TARGET_OS_LINUX) | 528 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |