Fix to find directory
Robert L Krawitz
rlk at mit-trillian.MIT.EDU
Thu Aug 14 12:13:22 AEST 1986
I goofed a little -- forgot to check stat's status. So giving a bogus
pathname following a directory will return the broken path as well.
Here's the fix.
/* fd -- echo arguments that are directories */
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
struct stat stats;
main(argc,argv)
int argc;
char **argv;
{
char *file;
argc--;
argv++;
while (argc > 0)
{
file = *argv;
if (stat(file, &stats) == 0)
if (((stats.st_mode) & S_IFMT) == S_IFDIR) printf ("%s\n", file);
argc--;
argv++;
}
}
--
Robert^Z
More information about the Comp.sources.bugs
mailing list