File::Spec::Link - Perl extension for reading and resolving symbolic links
use File::Spec::Link; my $file = File::Spec::Link->linked($link); my $file = File::Spec::Link->resolve($link); my $dirname = File::Spec::Link->chopfile($file); my $newname = File::Spec::Link->relative_to_file($path, $link); my $realname = File::Spec::Link->full_resolve($file); my $realname = File::Spec::Link->resolve_path($file); my $realname = File::Spec::Link->resolve_all($file);
File::Spec::Link is an extension to File::Spec, adding methods for resolving symbolic links; it was created to implement File::Copy::Link.
File::Spec::Link
File::Spec
File::Copy::Link
linked($link)
Returns the filename linked to by $link: by readlinking $link, and resolving that path relative to the directory of $link.
$link
readlink
resolve($link)
Returns the non-link ultimately linked to by $link, by repeatedly calling linked. Returns undef if the link can not be resolved.
linked
undef
chopfile($file)
Returns the directory of $file, by splitting the path of $file and returning (the volumne and) directory parts.
$file
relative_to_file($path, $file)
Returns the path of $path relative to the directory of file $file. If $path is absolute, just returns $path.
$path
resolve_all($file)
Returns the filename of $file with all links in the path resolved, wihout using Cwd.
Cwd
full_resolve($file)
Returns the filename of $file with all links in the path resolved.
This sub tries to use Cwd::abs_path via ->resolve_path.
Cwd::abs_path
->resolve_path
resolve_path($file)
This sub uses Cwd::abs_path and is independent of the rest of File::Spec::Link.
new([$path])
create new path object: stores path as a list
path
returns path as a string, using catpath
canonical
returns canonical path, using canonpath
vol
returns volume element of path, see File::Spec->splitpath
dir
returns directory element of path, as a string, see File::Spec->splitpath
dirs
return list of directory components in path, see File::Spec->splitdir
pop
remove last component of the path
push($file)
add a file component to the path, ignoring empty strings
add($file)
add a component to the path: treating updir as pop, and ignoring curdir and empty strings
updir
curdir
split($path)
populate a path object, using splitpath
chop
remove and return a file component from path, an empty string returns means this was root dir.
relative($path)
replace the path object with the supplied path, where the new path is relative to the path object
follow
follow the link, where the path object is a link
resolved
resolve the path object, by repeatedly following links
resolvedir
resolve the links at all component levels within the path object
canonpath($path)
Wrapper round File::Spec::canonpath, fatal if empty input
catdir(@dirs)
Wrapper round File::Spec::catdir, returns curdir from empty list
splitlast($path)
Get component from $path (using chop) and returns remaining path and compenent, as strings. [Not used]
None - all subs are methods for File::Spec::Link.
File::Spec(3) File::Copy::Link(3)
Robin Barker, <Robin.Barker@npl.co.uk>
Copyright 2003, 2005, 2006, 2007 by Robin Barker
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install File::Copy::Link, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Copy::Link
CPAN shell
perl -MCPAN -e shell install File::Copy::Link
For more information on module installation, please visit the detailed CPAN module installation guide.