Subject: Re: sys/stat.h: S_IFLNK
To: Chris G. Demetriou <cgd@sibyte.com>
From: =?iso-8859-1?Q?Thorbj=F6rn?= jemander <thoan@ifm.liu.se>
List: tech-misc
Date: 01/10/2001 04:34:47
"Chris G. Demetriou" wrote:
> thoan@ifm.liu.se (Thorbjorn Jemander) writes:
> > So, here's some really basic stuff.
> > Why do regular files trigger this test:
> >
> > if (file_stat.st_mode & S_IFMT == S_IFLNK) {
> > /* Symbolic link */
> > }
> >
> > ?
>
> I don't see how you'll _ever_ get into the /* Symbolic link */
> comment's block, there...
>
No, not with that typo, no. What I actually do is masking the
non-type bits with S_IFMT in a switch():
switch(file_stat.st_mode & S_IFMT) {
case S_IFLNK:
break;
case S_IFIFO:
break;
/* etc. */
}
Anyway, the problem is not priorities or masking, but the
interpretation of these flags and where I can read about them.
The man pages are not going into detail. I don't want to
plunge into the system source to find out.
/Thorbjörn