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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if (NO_RETRY_EXPECTED(lstat64(path->AsString(), &st)) == -1) { | 238 if (NO_RETRY_EXPECTED(lstat64(path->AsString(), &st)) == -1) { |
239 return false; | 239 return false; |
240 } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { | 240 } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { |
241 return (NO_RETRY_EXPECTED(unlink(path->AsString())) == 0); | 241 return (NO_RETRY_EXPECTED(unlink(path->AsString())) == 0); |
242 } | 242 } |
243 | 243 |
244 if (!path->Add(File::PathSeparator())) return false; | 244 if (!path->Add(File::PathSeparator())) return false; |
245 | 245 |
246 // Not a link. Attempt to open as a directory and recurse into the | 246 // Not a link. Attempt to open as a directory and recurse into the |
247 // directory. | 247 // directory. |
248 DIR* dir_pointer = opendir(path->AsString()); | 248 DIR* dir_pointer; |
| 249 do { |
| 250 dir_pointer = opendir(path->AsString()); |
| 251 } while (dir_pointer == NULL && errno == EINTR); |
249 if (dir_pointer == NULL) { | 252 if (dir_pointer == NULL) { |
250 return false; | 253 return false; |
251 } | 254 } |
252 | 255 |
253 // Iterate the directory and delete all files and directories. | 256 // Iterate the directory and delete all files and directories. |
254 int path_length = path->length(); | 257 int path_length = path->length(); |
255 dirent entry; | 258 dirent entry; |
256 dirent* result; | 259 dirent* result; |
257 while (NO_RETRY_EXPECTED(readdir_r(dir_pointer, &entry, &result)) == 0) { | 260 while (NO_RETRY_EXPECTED(readdir_r(dir_pointer, &entry, &result)) == 0) { |
258 if (result == NULL) { | 261 if (result == NULL) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 bool Directory::Rename(const char* path, const char* new_path) { | 436 bool Directory::Rename(const char* path, const char* new_path) { |
434 ExistsResult exists = Exists(path); | 437 ExistsResult exists = Exists(path); |
435 if (exists != EXISTS) return false; | 438 if (exists != EXISTS) return false; |
436 return NO_RETRY_EXPECTED(rename(path, new_path)) == 0; | 439 return NO_RETRY_EXPECTED(rename(path, new_path)) == 0; |
437 } | 440 } |
438 | 441 |
439 } // namespace bin | 442 } // namespace bin |
440 } // namespace dart | 443 } // namespace dart |
441 | 444 |
442 #endif // defined(TARGET_OS_LINUX) | 445 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |