|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T d
Length: 1057 (0x421) Types: TextFile Names: »descend.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦this⟧ »EUUGD11/euug-87hel/sec1/news/misc/search/lib/descend.c«
/* Recursively call 'process' for all files in a directory, and for all files in subdirectories, etc. Return code is 1 if the dir. couldn't be opened, else the OR of the return codes of all process calls. Don't let this loose on devices or other weird files like sockets... */ #include "defs.h" #include <sys/types.h> #include <sys/param.h> #include <sys/dir.h> int descend(name, process) char *name; funcptr process; { DIR *dirp= opendir(name); struct direct *dp; char namebuf[MAXPATHLEN]; char *ebuf; int status= 0; if (dirp == NULL) { perror(name); return 1; } strcpy(namebuf, name); ebuf= namebuf + strlen(namebuf); if (ebuf > namebuf && ebuf[-1] != SEP) { *ebuf++ = SEP; *ebuf= EOS; } while ((dp= readdir(dirp)) != NULL) { if (dp->d_name[0] == '.' && (dp->d_name[1] == EOS || dp->d_name[1] == '.' && dp->d_name[2] == EOS)) continue; strcpy(ebuf, dp->d_name); if (isdir(namebuf)) status |= descend(namebuf, process); else status |= (*process)(namebuf); } closedir(dirp); return status; }