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

Unified Diff: runtime/bin/directory_linux.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_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_linux.cc
diff --git a/runtime/bin/directory_linux.cc b/runtime/bin/directory_linux.cc
index f6ad163905b8daae5fcdce5dcae26e2c7c907cfb..a316633d8e5b76fccfa913b472c670a19c3792c1 100644
--- a/runtime/bin/directory_linux.cc
+++ b/runtime/bin/directory_linux.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,7 +234,6 @@ 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.
struct stat st;
if (TEMP_FAILURE_RETRY(lstat(path->data, &st)) == -1) {
@@ -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_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698