mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 18:36:29 +00:00
Handle non-regular files in recursive delete
Fix is similar to the fix for directory listing from last week. R=rmacnak@google.com Review-Url: https://codereview.chromium.org/2573143002 .
This commit is contained in:
parent
392c242df9
commit
4b9087f9f5
|
@ -259,7 +259,7 @@ static bool DeleteRecursively(PathBuffer* path) {
|
|||
struct stat st;
|
||||
if (NO_RETRY_EXPECTED(lstat(path->AsString(), &st)) == -1) {
|
||||
return false;
|
||||
} else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
|
||||
} else if (!S_ISDIR(st.st_mode)) {
|
||||
return (unlink(path->AsString()) == 0);
|
||||
}
|
||||
|
||||
|
@ -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,7 +317,7 @@ 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 {
|
||||
// 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.
|
||||
|
@ -322,6 +326,8 @@ static bool DeleteRecursively(PathBuffer* path) {
|
|||
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) {
|
||||
|
|
|
@ -257,7 +257,7 @@ static bool DeleteRecursively(PathBuffer* path) {
|
|||
struct stat64 st;
|
||||
if (TEMP_FAILURE_RETRY(lstat64(path->AsString(), &st)) == -1) {
|
||||
return false;
|
||||
} else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
|
||||
} else if (!S_ISDIR(st.st_mode)) {
|
||||
return (NO_RETRY_EXPECTED(unlink(path->AsString())) == 0);
|
||||
}
|
||||
|
||||
|
@ -301,6 +301,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
|
||||
|
@ -322,7 +326,7 @@ 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 {
|
||||
// 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.
|
||||
|
@ -331,6 +335,8 @@ static bool DeleteRecursively(PathBuffer* path) {
|
|||
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) {
|
||||
|
|
|
@ -259,7 +259,7 @@ static bool DeleteRecursively(PathBuffer* path) {
|
|||
struct stat st;
|
||||
if (NO_RETRY_EXPECTED(lstat(path->AsString(), &st)) == -1) {
|
||||
return false;
|
||||
} else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
|
||||
} else if (!S_ISDIR(st.st_mode)) {
|
||||
return (unlink(path->AsString()) == 0);
|
||||
}
|
||||
|
||||
|
@ -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,7 +317,7 @@ 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 {
|
||||
// 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.
|
||||
|
@ -322,6 +326,8 @@ static bool DeleteRecursively(PathBuffer* path) {
|
|||
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) {
|
||||
|
|
Loading…
Reference in a new issue