Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!topaz!ll-xn!mit-amt!mit-eddie!mit-trillian!rlk From: rlk@mit-trillian.MIT.EDU (Robert L Krawitz) Newsgroups: net.sources.bugs Subject: Fix to find directory Message-ID: <1005@mit-trillian.MIT.EDU> Date: Wed, 13-Aug-86 22:13:22 EDT Article-I.D.: mit-tril.1005 Posted: Wed Aug 13 22:13:22 1986 Date-Received: Thu, 14-Aug-86 20:21:50 EDT Reply-To: rlk@mit-athena.UUCP (Robert L Krawitz) Organization: MIT Project Athena Lines: 29 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 #include #include 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