site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com User-agent: Mutt/1.4i On Tue, Apr 25, 2006 at 01:11:09PM -0400, David Carpeneto wrote:
Playing with BSD File routines & it seems that *every* file I retrieve info on via readdir that isn't a directory or a pipe/fifo has "DT_LNK" set.
[...] DIR *dirp; struct dirent *dp;
dirp = opendir(argv[1]); while ((dp = readdir(dirp)) != NULL) { printf("NAME IS : %s", dp->d_name); if (dp->d_type & DT_UNKNOWN) printf("\t\tUNKNOWN"); if (dp->d_type & DT_DIR) printf("\t\tDIRECTORY"); if (dp->d_type & DT_LNK) printf("\t\tLINK"); if (dp->d_type & DT_FIFO) printf("\t\tPIPE"); printf("\n");
The DT_* constants are not flags.
From /usr/include/sys/dirent.h:
/* * File types */ #define DT_UNKNOWN 0 #define DT_FIFO 1 #define DT_CHR 2 #define DT_DIR 4 #define DT_BLK 6 #define DT_REG 8 #define DT_LNK 10 #define DT_SOCK 12 #define DT_WHT 14 So, you probably want to try using "==" instead of "&" in those tests. HTH --macko _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com