NAME

File::At - POSIX relative file handling

VERSION

version 0.001

SYNOPSIS

use Fcntl 'O_RDONLY';
use File::At 'openat';
my $fh = openat($dir, $path, O_RDONLY) or die "Could not open $path: $!";

DESCRIPTION

This module provides a series of filesystem functions with one or two extra dirhandle arguments. These will be used instead of the current directory for resolving relative paths. If undef is passed as a dirhandle, the current directory will be used instead.

Most functions return true on success, and undef on failure (setting $! in the process), unless specified otherwise.

FUNCTIONS

openat

openat($dirhandle, $path, $flags, $mode = 0666)

Open a file $path under $dirhandle. This returns a filehandle on success.

opendirat

opendirat($dirhandle, $path, $flags = O_RDONLY, $mode = 0666)

This opens a directory at $path under $dirhandle. This returns a filehandle on success.

faccessat

faccessat($dirhandle, $path, $mode, $flags = 0)

This checks the accessibility of file $path under $dirhandle.

fchmodat

fchmodat($dirhandle, $path, $mode, $flags = 0)

This changes the mode of the file $path under $dirhandle.

fchownat

fchownat($dirhandle, $path, $uid, $gid, $flags = 0)

This changes the ownership of the file $path under $dirhandle.

linkat

linkat($old_dirhandle, $old_path, $new_dirhandle, $new_path, $flags = 0)

This creates a link at <$new_path> under new_dirhandle that links to the same file as $old_path under $old_dirhandle.

mkdirat

mkdirat($dirhandle, $path, $flags = 0)

This makes a new directory $path under $dirhandle.

mkfifoat

mkfifoat($dirhandle, $path, $mode)

This creates a fifo at $path under $dirhandle.

mknodat

mknodat($dirhandle, $path, $mode, $dev)

This creates a device at $path under $dirhandle

readlinkat

readlinkat($dirhandle, $path)

This creates a device at $path under $dirhandle.

renameat

renameat($from_dirhandle, $from_path, $to_dirhandle, $to_path)

symlinkat

symlinkat($old_path, $dirhandle, $new_path)

This creates a symlink at <$new_path> under dirhandle that links to $old_path.

unlinkat

unlinkat($dirhandle, $path, $flags = 0)

This removes a file or directory $path under $dirhandle.

utimensat

utimensat($dirhandle, $path, $atime, $mtime)

This updates the times of $path under $dirhandle.

CONSTANTS

Various constants are defined to pass as flags parameter to some of these functions:

AT_EACCESS

Flag for faccessat, if enabled it will use the effective user and group IDs instead of the real ones.

AT_REMOVEDIR

Flag for unlink, if specified it performs the equivalent of rmdir on the path.

Flag for link. Linkat() does not dereference oldpath if it is a symbolic link unless this flag is given.

A flag for faccessat, fchmodat, fchownat, utimensat to stop them from following a symlink.

SEE ALSO

AUTHOR

Leon Timmermans <fawaka@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.