Applied patch from Vladimir to fix bug where find would stop as soon as it hit

a perms error. Closes bug 1124.
This commit is contained in:
Mark Whitley 2001-03-08 16:54:44 +00:00
parent 5de909873a
commit e2c44fc966

View File

@ -703,14 +703,15 @@ int recursive_action(const char *fileName,
perror_msg("%s", fileName); perror_msg("%s", fileName);
return FALSE; return FALSE;
} }
status = TRUE;
while ((next = readdir(dir)) != NULL) { while ((next = readdir(dir)) != NULL) {
char nextFile[BUFSIZ + 1]; char nextFile[PATH_MAX];
if ((strcmp(next->d_name, "..") == 0) if ((strcmp(next->d_name, "..") == 0)
|| (strcmp(next->d_name, ".") == 0)) { || (strcmp(next->d_name, ".") == 0)) {
continue; continue;
} }
if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) { if (strlen(fileName) + strlen(next->d_name) + 1 > PATH_MAX) {
error_msg(name_too_long); error_msg(name_too_long);
return FALSE; return FALSE;
} }
@ -719,26 +720,20 @@ int recursive_action(const char *fileName,
sprintf(nextFile, "%s%s", fileName, next->d_name); sprintf(nextFile, "%s%s", fileName, next->d_name);
else else
sprintf(nextFile, "%s/%s", fileName, next->d_name); sprintf(nextFile, "%s/%s", fileName, next->d_name);
status = if (recursive_action(nextFile, TRUE, followLinks, depthFirst,
recursive_action(nextFile, TRUE, followLinks, depthFirst, fileAction, dirAction, userData) == FALSE) {
fileAction, dirAction, userData); status = FALSE;
if (status == FALSE) {
closedir(dir);
return FALSE;
} }
} }
status = closedir(dir); closedir(dir);
if (status < 0) {
perror_msg("%s", fileName);
return FALSE;
}
if (dirAction != NULL && depthFirst == TRUE) { if (dirAction != NULL && depthFirst == TRUE) {
status = dirAction(fileName, &statbuf, userData); if (dirAction(fileName, &statbuf, userData) == FALSE) {
if (status == FALSE) {
perror_msg("%s", fileName); perror_msg("%s", fileName);
return FALSE; return FALSE;
} }
} }
if (status == FALSE)
return FALSE;
} else { } else {
if (fileAction == NULL) if (fileAction == NULL)
return TRUE; return TRUE;