i tried to use stat to get the attributes of a file and a soft link. but the result i got from stat and lstat are the same.
say:
ln -s f1 soft1 (soft is a soft link , point to f1)
if i use > ls -il
shows the inode and modify time of soft1 and f1 are different.
but the modify time( or any other attributes) are the same (using perl script) even if i use lstat for soft1 and stat for f1.
could anyone tell me why?
here is my code:
my \($fileName\) = shift;
open \(FILEINFO, "$fileName"\) || die "$! can't open";
\# get the attributes for the file and softlink
my\(@fileAttributes\) = stat\(FILEINFO\);
my\(@linkAttributes\) = lstat\(FILEINFO\);
close \(FILEINFO\);
\# check if the link is soft link
if \(-l $fileName\)
\{
$hashModifyTime\{$fileName\} = $linkAttributes[9];
print "^^^^^^$hashModifyTime\{$fileName\}\\n";
\}
else
\{
\# fileAttributes[9] contains the last modify time of the file
$hashModifyTime\{$fileName\} = $fileAttributes[9];
print "^^^^^^$hashModifyTime\{$fileName\}\\n";
\}