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

Unified Diff: runtime/bin/directory_macos.cc

Issue 2573143002: Handle non-regular files in recursive delete (Closed)
Patch Set: Created 4 years 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
« runtime/bin/directory_linux.cc ('K') | « runtime/bin/directory_linux.cc ('k') | no next file » | 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 c06ffa31fb799cbebf9df059b073ce51b1d39d87..40aec1978f91b48340b5d2f85e316b32a603e103 100644
--- a/runtime/bin/directory_macos.cc
+++ b/runtime/bin/directory_macos.cc
@@ -292,6 +292,10 @@ static bool DeleteRecursively(PathBuffer* path) {
case DT_DIR:
ok = DeleteDir(entry.d_name, path);
break;
+ case DT_BLK:
+ case DT_CHR:
+ case DT_FIFO:
+ case DT_SOCK:
case DT_REG:
case DT_LNK:
// Treat all links as files. This will delete the link which
@@ -313,15 +317,22 @@ static bool DeleteRecursively(PathBuffer* path) {
path->Reset(path_length);
if (S_ISDIR(entry_info.st_mode)) {
ok = DeleteDir(entry.d_name, path);
- } else if (S_ISREG(entry_info.st_mode) || S_ISLNK(entry_info.st_mode)) {
+ } else if (S_ISREG(entry_info.st_mode) || S_ISCHR(entry_info.st_mode) ||
rmacnak 2016/12/14 18:44:02 Keep S_ISLNK
zra 2016/12/14 20:48:07 Done.
+ S_ISBLK(entry_info.st_mode) ||
+ S_ISFIFO(entry_info.st_mode) ||
+ S_ISSOCK(entry_info.st_mode)) {
// Treat links as files. This will delete the link which is
// what we want no matter if the link target is a file or a
// directory.
ok = DeleteFile(entry.d_name, path);
+ } else {
+ FATAL1("Unexpected st_mode: %d\n", entry_info.st_mode);
}
break;
}
default:
+ // We should have covered all the bases. If not, let's get an error.
+ FATAL1("Unexpected d_type: %d\n", entry.d_type);
break;
}
if (!ok) {
« runtime/bin/directory_linux.cc ('K') | « runtime/bin/directory_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698