Index: zipscript/src/cleanup.c =================================================================== --- zipscript/src/cleanup.c (revision 2049) +++ zipscript/src/cleanup.c (working copy) @@ -167,7 +167,7 @@ DIR *dir; struct dirent *dp; - int i; + int i, fd; regex_t preg[4]; regmatch_t pmatch[1]; char temp[PATH_MAX]; @@ -197,11 +197,16 @@ while ((dp = readdir(dir))) for (i = 0; i < 4; i++) - if (regexec(&preg[i], dp->d_name, 1, pmatch, 0) == 0) + if ((fd = open(dp->d_name, O_NDELAY, 0777)) != -1) + close(fd); + else if (setfree) { + unlink(dp->d_name); + printf("Broken symbolic link \"%s\" removed.\n", dp->d_name); + i=5; + } else if (regexec(&preg[i], dp->d_name, 1, pmatch, 0) == 0) if (!(int)pmatch[0].rm_so && (int)pmatch[0].rm_eo == (int)NAMLEN(dp)) if (checklink(path, dp->d_name, setfree)) break; - closedir(dir); } else {