| 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 "bin/directory.h" | 5 #include "bin/directory.h" |
| 6 | 6 |
| 7 #include <dirent.h> | 7 #include <dirent.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <sys/param.h> | 9 #include <sys/param.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 DirectoryListing *listing) { | 64 DirectoryListing *listing) { |
| 65 if (strcmp(dir_name, ".") != 0 && | 65 if (strcmp(dir_name, ".") != 0 && |
| 66 strcmp(dir_name, "..") != 0) { | 66 strcmp(dir_name, "..") != 0) { |
| 67 size_t written = snprintf(path + path_length, | 67 size_t written = snprintf(path + path_length, |
| 68 PATH_MAX - path_length, | 68 PATH_MAX - path_length, |
| 69 "%s", | 69 "%s", |
| 70 dir_name); | 70 dir_name); |
| 71 if (written != strlen(dir_name)) { | 71 if (written != strlen(dir_name)) { |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 bool ok = listing->HandleDirectory(dir_name); | 74 bool ok = listing->HandleDirectory(path); |
| 75 if (!ok) return ok; | 75 if (!ok) return ok; |
| 76 if (recursive) { | 76 if (recursive) { |
| 77 return ListRecursively(path, recursive, listing); | 77 return ListRecursively(path, recursive, listing); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 static bool HandleFile(char* file_name, | 84 static bool HandleFile(char* file_name, |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 418 } |
| 419 | 419 |
| 420 | 420 |
| 421 bool Directory::Delete(const char* dir_name, bool recursive) { | 421 bool Directory::Delete(const char* dir_name, bool recursive) { |
| 422 if (!recursive) { | 422 if (!recursive) { |
| 423 return (TEMP_FAILURE_RETRY(remove(dir_name)) == 0); | 423 return (TEMP_FAILURE_RETRY(remove(dir_name)) == 0); |
| 424 } else { | 424 } else { |
| 425 return DeleteRecursively(dir_name); | 425 return DeleteRecursively(dir_name); |
| 426 } | 426 } |
| 427 } | 427 } |
| OLD | NEW |