perl stat windows 与 UNIX不同


在 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 system 1 Inode number 2 File mode (type and permissions) 3 Number of (hard) links to the file 4 Numeric user ID of file.s owner 5 Numeric group ID of file.s owner 6 The device identifier (special files only) 7 File size, in bytes 8 Last access time since the epoch 9 Last modify time since the epoch 10 Inode change time (not creation time!) since the epoch 11 Preferred block size for file system I/O 12 Actual number of blocks allocated window下值的描述
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




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值