| 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 <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 29 matching lines...) Expand all Loading... |
| 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() == STDOUT_FILENO) { | 48 if (handle_->fd() == STDOUT_FILENO) { |
| 49 // If stdout, redirect fd to /dev/null. | 49 // If stdout, redirect fd to /dev/null. |
| 50 int null_fd = TEMP_FAILURE_RETRY(open("/dev/null", O_WRONLY)); | 50 intptr_t null_fd = TEMP_FAILURE_RETRY(open("/dev/null", O_WRONLY)); |
| 51 ASSERT(null_fd >= 0); | 51 ASSERT(null_fd >= 0); |
| 52 VOID_TEMP_FAILURE_RETRY(dup2(null_fd, handle_->fd())); | 52 VOID_TEMP_FAILURE_RETRY(dup2(null_fd, handle_->fd())); |
| 53 VOID_TEMP_FAILURE_RETRY(close(null_fd)); | 53 VOID_TEMP_FAILURE_RETRY(close(null_fd)); |
| 54 } else { | 54 } else { |
| 55 int err = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(handle_->fd())); | 55 intptr_t err = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(handle_->fd())); |
| 56 if (err != 0) { | 56 if (err != 0) { |
| 57 const int kBufferSize = 1024; | 57 const int kBufferSize = 1024; |
| 58 char error_message[kBufferSize]; | 58 char error_message[kBufferSize]; |
| 59 strerror_r(errno, error_message, kBufferSize); | 59 strerror_r(errno, error_message, kBufferSize); |
| 60 Log::PrintErr("%s\n", error_message); | 60 Log::PrintErr("%s\n", error_message); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 handle_->set_fd(kClosedFd); | 63 handle_->set_fd(kClosedFd); |
| 64 } | 64 } |
| 65 | 65 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 return (file_1_info.st_ino == file_2_info.st_ino && | 383 return (file_1_info.st_ino == file_2_info.st_ino && |
| 384 file_1_info.st_dev == file_2_info.st_dev) ? | 384 file_1_info.st_dev == file_2_info.st_dev) ? |
| 385 File::kIdentical : | 385 File::kIdentical : |
| 386 File::kDifferent; | 386 File::kDifferent; |
| 387 } | 387 } |
| 388 | 388 |
| 389 } // namespace bin | 389 } // namespace bin |
| 390 } // namespace dart | 390 } // namespace dart |
| 391 | 391 |
| 392 #endif // defined(TARGET_OS_MACOS) | 392 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |