| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_FUCHSIA) | 6 #if defined(TARGET_OS_FUCHSIA) |
| 7 | 7 |
| 8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
| 9 | 9 |
| 10 #include <dirent.h> // NOLINT | 10 #include <dirent.h> // NOLINT |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 path_length_ = listing->path_buffer().length(); | 111 path_length_ = listing->path_buffer().length(); |
| 112 } | 112 } |
| 113 // Reset. | 113 // Reset. |
| 114 listing->path_buffer().Reset(path_length_); | 114 listing->path_buffer().Reset(path_length_); |
| 115 ResetLink(); | 115 ResetLink(); |
| 116 | 116 |
| 117 // Iterate the directory and post the directories and files to the | 117 // Iterate the directory and post the directories and files to the |
| 118 // ports. | 118 // ports. |
| 119 errno = 0; | 119 errno = 0; |
| 120 dirent* entry = readdir(reinterpret_cast<DIR*>(lister_)); | 120 dirent* entry = readdir(reinterpret_cast<DIR*>(lister_)); |
| 121 if (entry == NULL) { | |
| 122 perror("readdir failed: "); | |
| 123 } | |
| 124 if (entry != NULL) { | 121 if (entry != NULL) { |
| 125 if (!listing->path_buffer().Add(entry->d_name)) { | 122 if (!listing->path_buffer().Add(entry->d_name)) { |
| 126 done_ = true; | 123 done_ = true; |
| 127 return kListError; | 124 return kListError; |
| 128 } | 125 } |
| 129 // TODO(MG-450): When entry->d_type is filled out correctly, we can avoid | 126 // TODO(MG-450): When entry->d_type is filled out correctly, we can avoid |
| 130 // this call to stat(). | 127 // this call to stat(). |
| 131 struct stat64 entry_info; | 128 struct stat64 entry_info; |
| 132 int stat_success; | 129 int stat_success; |
| 133 stat_success = NO_RETRY_EXPECTED( | 130 stat_success = NO_RETRY_EXPECTED( |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 if (exists != EXISTS) { | 425 if (exists != EXISTS) { |
| 429 return false; | 426 return false; |
| 430 } | 427 } |
| 431 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); | 428 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); |
| 432 } | 429 } |
| 433 | 430 |
| 434 } // namespace bin | 431 } // namespace bin |
| 435 } // namespace dart | 432 } // namespace dart |
| 436 | 433 |
| 437 #endif // defined(TARGET_OS_FUCHSIA) | 434 #endif // defined(TARGET_OS_FUCHSIA) |
| OLD | NEW |