perl stat windows 与 UNIX不同

前端之家收集整理的这篇文章主要介绍了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

猜你在找的Perl相关文章