POSIX::1003::FS - POSIX for the file-system
use POSIX::1003::FS ':access'; if(access $fn, R_OK) # $fn is readible? use POSIX::1003::FS qw(mkfifo :stat); mkfifo($path, S_IRUSR|S_IWUSR) or die $!; # Absorbed from Unix::Mknod use POSIX::1003::FS qw(mknod major minor makedev); use File::stat my $st = stat '/dev/null'; my $major = major $st->rdev; my $minor = minor $st->rdev; mknod '/tmp/special', S_IFCHR|0600, makedev($major,$minor+1);
You may also need POSIX::1003::Pathconf.
Read man filetest before you start using this function! Use the *_OK constants for $flags.
man filetest
*_OK
Like chown(), but does not follow symlinks when encountered. Returns the number of files successfully changed.
chown()
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);
Simple CORE::mkdir()
CORE::mkdir()
Create a special device node on $path. Useful symbols for $mode can be collected from Fcntl (import tag :mode). The $device number is a combination from the type (major number), a sequence number and usage information (combined in a minor number).
:mode
[0.93] Give a file or directory a new name, the basis of the UNIX mv ('move') command. This will use CORE::rename().
mv
CORE::rename()
Be warned that Window's rename implementation will fail when $newname exists. That behavior is not POSIX compliant. On many platforms (especially the older), a rename between different partitions is not allowed.
rename
Simply CORE::utime()
CORE::utime()
Be Warned that POSIX.pm uses a different parameter order than CORE.
POSIX.pm
POSIX::utime($filename, $atime, $mtime); CORE::utime($atime, $mtime, @filenames);
example:
use File::stat 'stat'; if(S_ISDIR(stat($fn)->mode)) ... if(S_ISDIR((lstat $fn)[2])) ...
Combine $major and $minor into a single DEVICE number.
my $device = (stat $filename)[6]; my $device_type = major $device; my $sequence_nr = minor $device; my $device = makedev $major, $minor; mknod $specialfile, $mode, $device;
The following constants are exported, shown here with the values discovered during installation of this module. When you ask for :constants, you get all, but they are also grouped by tag.
:constants
Export POSIX::1003::FS subroutine stat and POSIX::1003::FS subroutine lstat including their related constants.
S_IFBLK 24576 S_IFSOCK 49152 S_IWGRP 16 S_IFCHR 8192 S_IRGRP 32 S_IWOTH 2 S_IFDIR 16384 S_IROTH 4 S_IWUSR 128 S_IFIFO 4096 S_IRUSR 256 S_IXGRP 8 S_IFLNK 40960 S_IRWXG 56 S_IXOTH 1 S_IFMT 61440 S_IRWXO 7 S_IXUSR 64 S_IFREG 32768 S_IRWXU 448
Exports function access() plus its related constants.
F_OK 0 NAME_MAX 255 W_OK 2 FILENAME_MAX 4096 PATH_MAX 4096 X_OK 1 MAX_CANON 255 R_OK 4
Load only the permission flags, and related functions mkfifo(), mknod(), mkdir(), and lchown(). Also, the common S_IS* C-level macro are provided as function.
S_IS*
The POSIX::1003::FS subroutine glob and POSIX::1003::FS subroutine fnmatch related constants.
GLOB_ALTDIRFUNC 512 GLOB_NOMAGIC 2048 GLOB_APPEND 32 GLOB_NOMATCH 3 GLOB_BRACE 1024 GLOB_NOSORT 4 GLOB_DOOFFS 8 GLOB_NOSPACE 1 GLOB_ERR 1 GLOB_ONLYDIR 8192 GLOB_MAGCHAR 256 GLOB_PERIOD 128 GLOB_MARK 2 GLOB_TILDE 4096 GLOB_NOCHECK 16 GLOB_TILDE_CHECK 16384 GLOB_NOESCAPE 64
This module is part of POSIX-1003 distribution version 0.99_03, built on February 07, 2015. Website: http://perl.overmeer.net. The code is based on POSIX, which is released with Perl itself. See also POSIX::Util for additional functionality.
Copyrights 2011-2015 on the perl code and the related documentation by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html
To install POSIX::1003, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POSIX::1003
CPAN shell
perl -MCPAN -e shell install POSIX::1003
For more information on module installation, please visit the detailed CPAN module installation guide.