Subject: Re: sys/stat.h: S_IFLNK
To: Thorbjorn Jemander <thoan@ifm.liu.se>
From: Chris G. Demetriou <cgd@sibyte.com>
List: tech-misc
Date: 01/09/2001 10:37:28
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...
== binds more tightly than arithmetic & (at least according to
/usr/share/misc/operator 8-).
the expression (S_IFMT == S_IFLNK) results in a value of 0.
so what you're really saying is:
if (file_stat.st_mode & 0) {
...
}
so I don't see how you're getting into the 'symbolic link' case at
all.
did you accurately present your test code?
cgd