|more useful options|
POSIX::S_ISDIR() with $stat->mode values from Windows vs. Linuxby isync (Hermit)
|on Oct 05, 2009 at 16:31 UTC||Need Help??|
isync has asked for the
wisdom of the Perl Monks concerning the following question:
I've got a script which can be run on Windows and Linux/Unix platforms. One function involves identifying if a directory entry is a dir or a file.
I differentiate with my $attr = POSIX::S_ISDIR($stat) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
On Win32 this works okay, but when the stat is issued on a Linux platform, the POSIX::S_ISDIR($stat1) does not work correctly.
Numeric return values differ between these two platforms-
On Win32, alimited set of possible return values (2):
16895 for a dir and 33206 for a file.
On Linux, depending on permissions, modes are for example:
16877 for a dir, 33188 for a file
I've been so far unable to fully wrap my head around bit operators, but as far as I understand it, POSIX::S_ISDIR should be able to differentiate between a number of possible values, especially these coming from a Linux filesystem. And not only the limited set of Win32 modes... Right? What am I missing?