| 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/directory.h" | 8 #include "bin/directory.h" |
| 9 | 9 |
| 10 #include <dirent.h> // NOLINT | 10 #include <dirent.h> // NOLINT |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 LinkList* next; | 72 LinkList* next; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 | 75 |
| 76 ListType DirectoryListingEntry::Next(DirectoryListing* listing) { | 76 ListType DirectoryListingEntry::Next(DirectoryListing* listing) { |
| 77 if (done_) { | 77 if (done_) { |
| 78 return kListDone; | 78 return kListDone; |
| 79 } | 79 } |
| 80 | 80 |
| 81 if (lister_ == 0) { | 81 if (lister_ == 0) { |
| 82 if (!listing->path_buffer().Add(File::PathSeparator())) { | |
| 83 done_ = true; | |
| 84 return kListError; | |
| 85 } | |
| 86 path_length_ = listing->path_buffer().length(); | |
| 87 do { | 82 do { |
| 88 lister_ = reinterpret_cast<intptr_t>( | 83 lister_ = reinterpret_cast<intptr_t>( |
| 89 opendir(listing->path_buffer().AsString())); | 84 opendir(listing->path_buffer().AsString())); |
| 90 } while (lister_ == 0 && errno == EINTR); | 85 } while (lister_ == 0 && errno == EINTR); |
| 91 | 86 |
| 92 if (lister_ == 0) { | 87 if (lister_ == 0) { |
| 93 done_ = true; | 88 done_ = true; |
| 94 return kListError; | 89 return kListError; |
| 95 } | 90 } |
| 91 if (parent_ != NULL) { |
| 92 if (!listing->path_buffer().Add(File::PathSeparator())) { |
| 93 return kListError; |
| 94 } |
| 95 } |
| 96 path_length_ = listing->path_buffer().length(); |
| 96 } | 97 } |
| 97 // Reset. | 98 // Reset. |
| 98 listing->path_buffer().Reset(path_length_); | 99 listing->path_buffer().Reset(path_length_); |
| 99 ResetLink(); | 100 ResetLink(); |
| 100 | 101 |
| 101 // Iterate the directory and post the directories and files to the | 102 // Iterate the directory and post the directories and files to the |
| 102 // ports. | 103 // ports. |
| 103 int status = 0; | 104 int status = 0; |
| 104 dirent entry; | 105 dirent entry; |
| 105 dirent* result; | 106 dirent* result; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 bool Directory::Rename(const char* path, const char* new_path) { | 426 bool Directory::Rename(const char* path, const char* new_path) { |
| 426 ExistsResult exists = Exists(path); | 427 ExistsResult exists = Exists(path); |
| 427 if (exists != EXISTS) return false; | 428 if (exists != EXISTS) return false; |
| 428 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); | 429 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); |
| 429 } | 430 } |
| 430 | 431 |
| 431 } // namespace bin | 432 } // namespace bin |
| 432 } // namespace dart | 433 } // namespace dart |
| 433 | 434 |
| 434 #endif // defined(TARGET_OS_MACOS) | 435 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |