File-Find-Node
view release on metacpan or search on metacpan
lib/File/Find/Node.pm view on Meta::CPAN
0, # LEVEL
0, # PRUNE
0, # FOLLOW
undef, # PARENT
undef, # PROCESS
undef, # POSTPROC
undef, # FILTER
undef, # ERRPROC
undef, # STAT
undef, # ARG
{}, # USER cache for getpwuid()
{}, # GROUP cache for getgrgid()
0 # MAXFORK
];
$self->[NAME] =~ s{.*/}{};
bless($self);
}
#
# private object methods
#
lib/File/Find/Node.pm view on Meta::CPAN
sub gid {
shift->[STAT]->[5];
}
sub user {
my $self = shift;
my $uid = $self->uid;
if (exists($self->[USER]->{$uid})) {
return $self->[USER]->{$uid};
}
my $user = getpwuid($uid);
$self->[USER]->{$uid} = defined($user) ? $user : $uid;
}
sub group {
my $self = shift;
my $gid = $self->gid;
if (exists($self->[GROUP]->{$gid})) {
return $self->[GROUP]->{$gid};
}
my $group = getgrgid($gid);
lib/File/Find/Node.pm view on Meta::CPAN
Returns the number of hard links.
=item $f->uid
Returns the user id number.
=item $f->user
Returns the user name or else returns the user id
number if getpwuid() fails. Uses a cache to avoid
extra calls to getpwuid().
=item $f->gid
Returns the group id number.
=item $f->group
Returns the group name or else returns the group id
number if getgrgid() fails. Uses a cache to avoid
extra calls to getgrgid().
@stat2 = $f->stat;
@stat3 = ($f->dev, $f->inum, $f->mode, $f->links, $f->uid,
$f->gid, $f->rdev, $f->size, $f->atime, $f->mtime,
$f->ctime, $f->blksize, $f->blocks);
ok($f->perm == ($f->mode & 07777), "test perm() method");
ok($f->ino == $f->inum,
"test ino() and inum() methods are the same");
ok($f->links == $f->nlink,
"test links() and nlink() methods are the same");
my $user = getpwuid($f->uid);
ok($f->user eq $user || $f->user == $f->uid,
"test user() method");
my $group = getgrgid($f->gid);
ok($f->group eq $group || $f->group == $f->gid,
"test group() method");
});
$f->find;
is_deeply(\@stat1, \@stat2, "test stat() method");
is_deeply(\@stat1, \@stat3,
( run in 0.445 second using v1.01-cache-2.11-cpan-8d75d55dd25 )