| 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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 bool Directory::Rename(const char* path, const char* new_path) { | 445 bool Directory::Rename(const char* path, const char* new_path) { |
| 443 ExistsResult exists = Exists(path); | 446 ExistsResult exists = Exists(path); |
| 444 if (exists != EXISTS) return false; | 447 if (exists != EXISTS) return false; |
| 445 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); | 448 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); |
| 446 } | 449 } |
| 447 | 450 |
| 448 } // namespace bin | 451 } // namespace bin |
| 449 } // namespace dart | 452 } // namespace dart |
| 450 | 453 |
| 451 #endif // defined(TARGET_OS_ANDROID) | 454 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |