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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 if (NO_RETRY_EXPECTED(lstat(path->AsString(), &st)) == -1) { | 237 if (NO_RETRY_EXPECTED(lstat(path->AsString(), &st)) == -1) { |
238 return false; | 238 return false; |
239 } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { | 239 } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { |
240 return (unlink(path->AsString()) == 0); | 240 return (unlink(path->AsString()) == 0); |
241 } | 241 } |
242 | 242 |
243 if (!path->Add(File::PathSeparator())) return false; | 243 if (!path->Add(File::PathSeparator())) return false; |
244 | 244 |
245 // Not a link. Attempt to open as a directory and recurse into the | 245 // Not a link. Attempt to open as a directory and recurse into the |
246 // directory. | 246 // directory. |
247 DIR* dir_pointer = opendir(path->AsString()); | 247 DIR* dir_pointer; |
| 248 do { |
| 249 dir_pointer = opendir(path->AsString()); |
| 250 } while (dir_pointer == NULL && errno == EINTR); |
248 if (dir_pointer == NULL) { | 251 if (dir_pointer == NULL) { |
249 return false; | 252 return false; |
250 } | 253 } |
251 | 254 |
252 // Iterate the directory and delete all files and directories. | 255 // Iterate the directory and delete all files and directories. |
253 int path_length = path->length(); | 256 int path_length = path->length(); |
254 dirent entry; | 257 dirent entry; |
255 dirent* result; | 258 dirent* result; |
256 while (NO_RETRY_EXPECTED(readdir_r(dir_pointer, &entry, &result)) == 0) { | 259 while (NO_RETRY_EXPECTED(readdir_r(dir_pointer, &entry, &result)) == 0) { |
257 if (result == NULL) { | 260 if (result == NULL) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 bool Directory::Rename(const char* path, const char* new_path) { | 425 bool Directory::Rename(const char* path, const char* new_path) { |
423 ExistsResult exists = Exists(path); | 426 ExistsResult exists = Exists(path); |
424 if (exists != EXISTS) return false; | 427 if (exists != EXISTS) return false; |
425 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); | 428 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); |
426 } | 429 } |
427 | 430 |
428 } // namespace bin | 431 } // namespace bin |
429 } // namespace dart | 432 } // namespace dart |
430 | 433 |
431 #endif // defined(TARGET_OS_MACOS) | 434 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |