[Developers] Bug fix for bug 1864 on all platforms.
Tom Goodale
goodale at cct.lsu.edu
Thu Jun 23 10:08:14 CDT 2005
On Thu, 23 Jun 2005, Jonathan Thornburg wrote:
> Hi,
>
>> We query the st_mode parameter set by the stat command. We can test if this
>> parameter is pointing to a directory by doing a "bitwise and" with 0040000
>> which is the value of S_IFDIR. This constant is also present in Windows but
>> it
>> is called _S_IFDIR. This patch will work on windows as the value of
>> _S_IFDIR is
>> also 0040000. This is same on all the platforms only the name of the
>> constant is
>> different. For example, the same constant is called S_IFDIR in Linux but it
>> has
>> the same value as above.
>
> Ick. *Please* don't embed OS-specific assumptions like this!
> You have know way of knowing if (say) one of the BSDs -- or AIX or
> IRIX or any of the 6.02e23 other operating systems on which we need
> to run Cactus -- uses a different value for this bit mask, or even
> encodes things in some form other than a bit mask.
>
> There's a reason POSIX defines S_IFDIR() MACRO rather than the bit
> fields, namely portability. We should use the macro on all POSIX
> platforms.
>
In util/File.c we have
/* some systems (eg. Windows NT) don't define this macro */
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
to get around this problem, and this has been compiling everywhere.
Please try this and update the patch if it works.
Tom
More information about the Developers
mailing list