While these file tests are fine for testing various attributes regarding a particular file or filehandle, they don't tell the whole story. To get at the remaining information about a file, merely call the stat
function, which returns pretty much everything that the POSIX system call stat
returns (hopefully more than you want to know). Not all of the stat
fields are meaningful under Perl for Win32, because they include information not supported by the Windows NT filesystems.
The operand to stat
is a filehandle or an expression that evaluates to a filename. The return value is either undef
, indicating that the stat failed, or a 13-element list,[] most easily described using the following list of scalar variables:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,
$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(...)
Table 10.2 lists each field along with a brief description.
Table 10.2: stat Return ValvesField | Description |
---|
dev | Device number (drive number) |
ino | Inode number: 0 (zero) in Perl for Win32 |
mode | File permission mode: read/write/execute |
nlink | Number of links to file (usually one for Win32 systems - NTFS filesystems may have a value greater than one) |
uid | User ID - zero for Win32 |
gid | Group ID - zero for Win32 |
rdev | Device Identifier (drive number) |
size | File size in bytes |
atime | Last access time (C lang. time_t value) |
mtime | Last modification time (C lang. time_t value) |
ctime | File creation time (C lang. time_t value) |
blksize | Disk block size (cluster size): zero for Win32 |
blocks | Number of blocks for file: zero for Win32 |
Like the file tests, the operand of stat
defaults to $_
, meaning that the stat will be performed on the file named by the scalar variable $_
.
You can retrieve information about the filesystem of the current active drive using the Win32::FsType
function:
$fstype = Win32::FsType;
if ($fstype =~ /NTFS/) {
print "NTFS -- good choice!\n";
}