POSIX-1003
view release on metacpan or search on metacpan
lib/POSIX/1003/FS.pm view on Meta::CPAN
use warnings;
use strict;
my (@constants, @access, @stat, @glob);
# POSIX.xs defines L_ctermid L_cuserid L_tmpname: useless!
my @functions = qw/
mkfifo mknod stat lstat rename
access lchown
utime
major minor makedev
/;
our @IN_CORE = qw(utime mkdir stat lstat rename);
our %EXPORT_TAGS =
( constants => \@constants
, functions => \@functions
, access => \@access
lib/POSIX/1003/FS.pm view on Meta::CPAN
push @constants, keys %$fsys;
# initialize the :access export tag
@access = qw/access/;
push @access, grep /_OK$|MAX/, keys %$fsys;
my %access_subset;
@access_subset{@access} = @{$fsys}{@access};
tie %access, 'POSIX::1003::ReadOnlyTable', \%access_subset;
# initialize the :stat export tag
@stat = qw/stat lstat mkfifo mknod mkdir lchown
S_ISDIR S_ISCHR S_ISBLK S_ISREG S_ISFIFO S_ISLNK S_ISSOCK S_ISWHT
/;
push @stat, grep /^S_I/, keys %$fsys;
my %stat_subset;
@stat_subset{@stat} = @{$fsys}{@stat};
tie %stat, 'POSIX::1003::ReadOnlyTable', \%stat_subset;
# initialize the :fsys export tag
@glob = qw/posix_glob fnmatch/;
push @glob, grep /^(?:GLOB|FNM|WRDE)_/, keys %$fsys;
lib/POSIX/1003/FS.pm view on Meta::CPAN
sub S_ISDIR($) { ($_[0] & S_IFMT()) == S_IFDIR()}
sub S_ISCHR($) { ($_[0] & S_IFMT()) == S_IFCHR()}
sub S_ISBLK($) { ($_[0] & S_IFMT()) == S_IFBLK()}
sub S_ISREG($) { ($_[0] & S_IFMT()) == S_IFREG()}
sub S_ISFIFO($) { ($_[0] & S_IFMT()) == S_IFIFO()}
sub S_ISLNK($) { ($_[0] & S_IFMT()) == S_IFLNK()}
sub S_ISSOCK($) { ($_[0] & S_IFMT()) == S_IFSOCK()}
sub S_ISWHT($) { ($_[0] & S_IFMT()) == S_IFWHT()} # FreeBSD
sub lchown($$@)
{ my ($uid, $gid) = (shift, shift);
my $successes = 0;
POSIX::lchown($uid, $gid, $_) && $successes++ for @_;
$successes;
}
sub posix_glob($%)
{ my ($patterns, %args) = @_;
my $flags = $args{flags}
// $glob{GLOB_NOSORT}|$glob{GLOB_NOESCAPE}|$glob{GLOB_BRACE};
my $errfun = $args{on_error} || sub {0};
lib/POSIX/1003/FS.pod view on Meta::CPAN
Still, this happens on bytes... there is a possibility that different
byte strings display the same in utf8 space.
=back
example:
my ($err, $fns) = glob(\@roots, flags => GLOB_NOSORT|GLOB_MARK,
on_error => sub { warn "skip $_[0]: error $_[1]"; 0} )
=item B<lchown>($uid, $gid, $filenames)
Like C<chown()>, but does not follow symlinks when encountered. Returns
the number of files successfully changed.
B<Be Warned> that the POSIX specification uses different parameter
order. For Perl was decided to accept a list of filenames. Passing more
than one filename, however, hinders correct error reporting.
# POSIX specification:
# int lchown(const char *path, uid_t owner, gid_t group);
# Perl core implementation:
my $successes = chown($uid, $gid, @filenames);
use POSIX;
POSIX::lchown($uid, $gid, $filename) or die $!;
use POSIX::1003::FS 'lchown';
my @successes = lchown($uid, $gid, @filenames);
=item B<lstat>( [$fh|$fn|$dirfh] )
Simply C<CORE::lstat()>. See also L<stat()|POSIX::1003::FS/"Standard POSIX">
=item B<mkdir>( [$filename [$mask]] )
Simple C<CORE::mkdir()>
=item B<mkfifo>($filename, $mode)
lib/POSIX/1003/FS.pod view on Meta::CPAN
=head1 CONSTANTS
The following constants are exported, shown here with the values
discovered during installation of this module. When you ask for
C<:constants>, you get all, but they are also grouped by tag.
=head2 export tag :stat
Export L<stat()|POSIX::1003::FS/"Standard POSIX"> and L<lstat()|POSIX::1003::FS/"Standard POSIX"> including their related constants.
Besides, the node related functions L<mkfifo()|POSIX::1003::FS/"Standard POSIX">, L<mknod()|POSIX::1003::FS/"Standard POSIX">, L<mkdir()|POSIX::1003::FS/"Standard POSIX">,
and L<lchown()|POSIX::1003::FS/"Standard POSIX">. Also, the common C<S_IS*> C-level macro are provided
as function.
=for comment
#TABLE_FSYS_STAT_START
During installation, a symbol table will get inserted here.
=for comment
#TABLE_FSYS_STAT_END
lib/POSIX/1003/Symbols.pm view on Meta::CPAN
EXDEV
EXFULL
strerror
) ],
filesystem => [ qw(
%access
%stat
access
F_OK
FILENAME_MAX
lchown
lstat
major
makedev
MAX_CANON
minor
mkfifo
mknod
NAME_MAX
PATH_MAX
R_OK
lib/POSIX/Overview.pod view on Meta::CPAN
::FdIO/tellfd
=head2 FIFO Interfaces
mkfifo ::FS
mkfifoat not supported
mknodat not supported
=head2 File Attribute Interfaces
Perl's C<chown> and C<chmod> accept both file names and file handles. Be
warned that the order of the parameters is different!
chmod perlfunc
chown perlfunc
fchmod perlfunc/chmod
fchown perlfunc/chown
umask perlfunc
fchmodat not supported
fchownat not supported
The symbolic constants for C<chmod> are provided by L<Fcntl> (and
POSIX.pm)
=head2 Thread-Safe Stdio Locking Interfaces
Perl does support the non-portable flock (see L<perlfunc/flock>)
in core, but the POSIX C<flockfile> mechanism is unsupported by
the PerlIO layers:
lib/POSIX/Overview.pod view on Meta::CPAN
getenv perlvar/%ENV $ENV{PATH}
setenv perlvar/%ENV $ENV{HOME} = '/tmp'
sysconf ::Sysconf
uname ::OS
unsetenv perlvar/%ENV delete $ENV{PS1}
The error constants are provided by L<Errno|Errno>.
=head2 Symbolic Link Interfaces
lchown ::FS
lstat perlfunc
readlinkat not supported
readlink perlfunc
symlinkat not supported
symlink perlfunc
B<Warning,> POSIX.pm accepts only one filename
CORE::chown($uid, $gid, @filename);
::FS::lchown($uid, $gid, @symlinks);
POSIX::lchown($uid, $gid, $symlink); # !!!
=head2 System Database Interfaces
getgrgid perlfunc User::grent
getgrnam perlfunc User::grent
getpwnam perlfunc User::pwent
getpwuid perlfunc User::pwent
=head2 Timer Interfaces
( run in 1.175 second using v1.01-cache-2.11-cpan-5511b514fd6 )