Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2378)

Unified Diff: runtime/bin/directory_macos.cc

Issue 13578003: Fix directory-listing, directory-deletion and file deletion, when links are involved. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use Link for Link removal. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/directory_linux.cc ('k') | runtime/bin/directory_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_macos.cc
diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc
index d66a809ac1cea6057582e34bb20614a846530cc1..401f80cf94d89ef0549d3601cef4dd466eb90200 100644
--- a/runtime/bin/directory_macos.cc
+++ b/runtime/bin/directory_macos.cc
@@ -169,6 +169,9 @@ static bool ListRecursively(PathBuffer* path,
int stat_success;
if (follow_links) {
stat_success = TEMP_FAILURE_RETRY(stat(path->data, &entry_info));
+ if (stat_success == -1) {
+ stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
+ }
} else {
stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
}
@@ -189,7 +192,6 @@ static bool ListRecursively(PathBuffer* path,
path,
listing) && success;
} else if (S_ISLNK(entry_info.st_mode)) {
- ASSERT(!follow_links);
success = HandleLink(entry.d_name,
path,
listing) && success;
@@ -232,8 +234,7 @@ static bool DeleteDir(char* dir_name,
static bool DeleteRecursively(PathBuffer* path) {
- if (!path->Add(File::PathSeparator())) return false;
- // Do not recurse into links for deletion. Instead delete the link.
+ // Do not recurse into links for deletion. Instead delete the link.
struct stat st;
if (TEMP_FAILURE_RETRY(lstat(path->data, &st)) == -1) {
return false;
@@ -241,6 +242,8 @@ static bool DeleteRecursively(PathBuffer* path) {
return (remove(path->data) == 0);
}
+ if (!path->Add(File::PathSeparator())) return false;
+
// Not a link. Attempt to open as a directory and recurse into the
// directory.
DIR* dir_pointer;
« no previous file with comments | « runtime/bin/directory_linux.cc ('k') | runtime/bin/directory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698