Filesys-POSIX
view release on metacpan or search on metacpan
lib/Filesys/POSIX.pm view on Meta::CPAN
sub lstat {
my ( $self, $path ) = @_;
return $self->_find_inode($path);
}
=item C<$fs-E<gt>fstat($fd)>
Return the inode corresponding to the open file descriptor passed. An
exception will be thrown by the file descriptor lookup module if the file
descriptor passed does not correspond to an open file.
=cut
sub fstat {
my ( $self, $fd ) = @_;
return $self->{'fds'}->lookup($fd)->{'inode'};
}
=item C<$fs-E<gt>chdir($path)>
Change the current working directory to the path specified. An
C<$fs-E<gt>stat()> call will be used internally to lookup the inode for that
path; an ENOTDIR will be thrown unless the inode found is a directory. The
internal current working directory pointer will be updated with the directory
inode found; this same inode will also be returned.
=cut
sub chdir {
my ( $self, $path ) = @_;
my $inode = $self->stat($path);
$! = 0;
throw &Errno::ENOTDIR unless $inode->dir;
return $self->{'cwd'} = $inode;
}
=item C<$fs-E<gt>fchdir($fd)>
When passed a file descriptor for a directory, update the internal pointer to
the current working directory to that directory resolved from the file
descriptor table, and return the same directory inode. If the inode is not a
directory, an ENOTDIR will be thrown.
=cut
sub fchdir {
my ( $self, $fd ) = @_;
my $inode = $self->fstat($fd);
$! = 0;
throw &Errno::ENOTDIR unless $inode->dir;
return $self->{'cwd'} = $inode;
}
=item C<$fs-E<gt>chown($path, $uid, $gid)>
Using C<$fs-E<gt>stat()> to locate the inode of the path specified, update that
inode object's 'uid' and 'gid' fields with the values specified. The inode of
the file modified will be returned.
=cut
sub chown {
my ( $self, $path, $uid, $gid ) = @_;
my $inode = $self->stat($path);
$inode->chown( $uid, $gid );
return $inode;
}
=item C<$fs-E<gt>fchown($fd, $uid, $gid)>
Using C<$fs-E<gt>fstat()> to locate the inode of the file descriptor specified,
update that inode object's 'uid' and 'gid' fields with the values specified. A
reference to the affected inode will be returned.
=cut
sub fchown {
my ( $self, $fd, $uid, $gid ) = @_;
my $inode = $self->fstat($fd);
$inode->chown( $uid, $gid );
return $inode;
}
=item C<$fs-E<gt>chmod($path, $mode)>
Using C<$fs-E<gt>stat()> to locate the inode of the path specified, update that
inode object's 'mode' field with the value specified. A reference to the
affected inode will be returned.
=cut
sub chmod {
my ( $self, $path, $mode ) = @_;
my $inode = $self->stat($path);
$inode->chmod($mode);
return $inode;
}
=item C<$fs-E<gt>fchmod($fd, $mode)>
Using C<$fs-E<gt>fstat()> to locate the inode of the file descriptor specified,
update that inode object's 'mode' field with the value specified. A reference
to that inode will be returned.
=cut
sub fchmod {
my ( $self, $fd, $mode ) = @_;
my $inode = $self->fstat($fd);
$inode->chmod($mode);
return $inode;
}
=item C<$fs-E<gt>mkdir($path)>
=item C<$fs-E<gt>mkdir($path, $mode)>
Create a new directory at the path specified, applying the permissions field in
the mode value specified. If no mode is specified, the default permissions of
I<0777> will be modified by the current umask value. An ENOTDIR exception will
be thrown in case the intended parent of the directory to be created is not
actually a directory itself.
A reference to the newly-created directory inode will be returned.
=cut
sub mkdir {
my ( $self, $path, $mode ) = @_;
my $hier = Filesys::POSIX::Path->new($path);
my $name = $hier->basename;
my $parent = $self->stat( $hier->dirname );
my $perm = $mode ? $mode & ( $S_IPERM | $S_IPROT ) : $S_IPERM ^ $self->{'umask'};
return $parent->child( $name, $perm | $S_IFDIR );
( run in 1.816 second using v1.01-cache-2.11-cpan-71847e10f99 )