perl stat windows 与 UNIX不同

来源:互联网 发布:米德尔顿 知乎 编辑:程序博客网 时间:2024/04/26 09:06

在 windows perl 下运行如下程序:

sub stat{    my ($filename) = @_;    my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksizes, $blocks) = stat($filename);    print "filename is $filename:\n";    print "Dev is $dev, Inode is $ino, Mode is $mode\n";    print "nlink is $nlink, Uid is $uid, Gid is $gid\n";    print "rdev is $rdev, Size is $size\n";    print "atime is $atime, mtime is $mtime, ctime is $ctime\n";    print "blkszies is $blksizes, blocks is $blocks\n";}sub get_stat{    foreach my $filename (@ARGV)    {        &stat($filename);    }}

&get_stat();

运行时输入:stat test.1 test.2

结果得到的Dev 和inode 两个文件是相同的。而在UNIX环境下,这两者可以唯一确定一个文件!

google了一下发现, stat 函数在 windows 中某些值是得不到的(某些值为0)!

1.) UNIX值的描述:

0 Device number of file system1 Inode number2 File mode (type and permissions)3 Number of (hard) links to the file4 Numeric user ID of file.s owner5 Numeric group ID of file.s owner6 The device identifier (special files only)7 File size, in bytes8 Last access time since the epoch9 Last modify time since the epoch10 Inode change time (not creation time!) since the epoch11 Preferred block size for file system I/O12Actual number of blocks allocatedwindow下值的描述Table 10.2: stat Return Valves

Field

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




原创粉丝点击