| 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_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include "bin/file.h" | 8 #include "bin/file.h" |
| 9 | 9 |
| 10 #include <copyfile.h> // NOLINT | 10 #include <copyfile.h> // NOLINT |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 void set_fd(int fd) { fd_ = fd; } | 34 void set_fd(int fd) { fd_ = fd; } |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 int fd_; | 37 int fd_; |
| 38 | 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(FileHandle); | 39 DISALLOW_COPY_AND_ASSIGN(FileHandle); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 | 42 |
| 43 File::~File() { | 43 File::~File() { |
| 44 if (!IsClosed()) { | 44 if (!IsClosed() && |
| 45 handle_->fd() != STDOUT_FILENO && handle_->fd() != STDERR_FILENO) { |
| 45 Close(); | 46 Close(); |
| 46 } | 47 } |
| 47 delete handle_; | 48 delete handle_; |
| 48 } | 49 } |
| 49 | 50 |
| 50 | 51 |
| 51 void File::Close() { | 52 void File::Close() { |
| 52 ASSERT(handle_->fd() >= 0); | 53 ASSERT(handle_->fd() >= 0); |
| 53 if (handle_->fd() == STDOUT_FILENO) { | 54 if (handle_->fd() == STDOUT_FILENO) { |
| 54 // If stdout, redirect fd to /dev/null. | 55 // If stdout, redirect fd to /dev/null. |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 return ((file_1_info.st_ino == file_2_info.st_ino) && | 483 return ((file_1_info.st_ino == file_2_info.st_ino) && |
| 483 (file_1_info.st_dev == file_2_info.st_dev)) ? | 484 (file_1_info.st_dev == file_2_info.st_dev)) ? |
| 484 File::kIdentical : | 485 File::kIdentical : |
| 485 File::kDifferent; | 486 File::kDifferent; |
| 486 } | 487 } |
| 487 | 488 |
| 488 } // namespace bin | 489 } // namespace bin |
| 489 } // namespace dart | 490 } // namespace dart |
| 490 | 491 |
| 491 #endif // defined(TARGET_OS_MACOS) | 492 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |