File::Spec::Link(3pm)
π File::Spec::Link π
okay bestie, quick vibe check: this page comes from the User Contributed Perl Documentation, and it's all about a little Perl module called File::Spec::Link (that's section 3pm, for the record). buckle up, it's giving symlink girlboss energy π¦β¨
πΈ NAME πΈ
File::Spec::Link β a Perl extension for reading and resolving symbolic links π₯
β¨ SYNOPSIS β¨
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);
π DESCRIPTION π
File::Spec::Link is literally an extension to File::Spec, and what it does is add methods for resolving symbolic links π
it exists because File::Copy::Link needed it to exist. main character supporting role, we love to see it.
linked($link)β hands you back the filename that$linkis linked to. how? byreadlinking$link, and then resolving that path relative to the directory that$linklives in. slay πresolve($link)β gives you the non-link that$linkultimately points at, by repeatedly callinglinkedover and over until it stops being a link. if the link can't be resolved at all? you getundef. no cap, that's just how it is πchopfile($file)β returns the directory of$file, by splitting the path of$fileand returning the (volumne and) directory parts. yes bestie she wrote "volumne", we're keeping her typo, it's iconic π«Άrelative_to_file($path, $file)β returns the path of$pathrelative to the directory of the file$file. but if$pathis absolute? it just returns$path. periodt.resolve_all($file)β returns the filename of$filewith all the links in the path resolved, wihout usingCwd. (again, her spelling, her rules π)full_resolve($file)β returns the filename of$filewith all the links in the path resolved. this sub tries to useCwd::abs_pathvia->resolve_path. β¨resolve_path($file)β returns the filename of$filewith all the links in the path resolved. this sub usesCwd::abs_pathand is independent of the rest ofFile::Spec::Link. she's self-sufficient, she don't need nobody π
π Object methods π
new([$path])β create a new path object: stores the path as a list πΈpathβ returns the path as a string, usingcatpathcanonicalβ returns the canonical path, usingcanonpathvolβ returns the volume element of the path, seeFile::Spec->splitpathdirβ returns the directory element of the path, as a string, seeFile::Spec->splitpathdirsβ return the list of directory components in the path, seeFile::Spec->splitdirpopβ remove the last component of the path πpush($file)β add a file component to the path, ignoring empty stringsadd($file)β add a component to the path: treatingupdiraspop, and ignoringcurdirand empty stringssplit($path)β populate a path object, usingsplitpathchopβ remove and return a file component from the path. an empty string coming back means this was the root dir πrelative($path)β replace the path object with the supplied path, where the new path is relative to the path objectfollowβ follow the link, where the path object is a link π¦resolvedβ resolve the path object, by repeatedly following linksresolvedirβ resolve the links at all component levels within the path object β
π Other class methods π
canonpath($path)β a wrapper roundFile::Spec::canonpath, and it goes fatal if the input is empty. so don't do that bestie.catdir(@dirs)β a wrapper roundFile::Spec::catdir, returnscurdirfrom an empty list πsplitlast($path)β get a component from$path(usingchop) and return the remaining path and the compenent, as strings. [Not used] β she's just sitting there, vibing, unused. we still list her though π
π§ EXPORT π§
None β all subs are methods for File::Spec::Link. no exports, we're classy like that π
π SEE ALSO π
File::Spec(3) File::Copy::Link(3)
π«Ά AUTHOR π«Ά
Robin Barker, <RMBarker@cpan.org>
β COPYRIGHT AND LICENSE β
Copyright 2003, 2005, 2006, 2007, 2011, 2014, 2024 by Robin Barker
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay that's the whole page, no notes, you ate π
and that's a wrap on File::Spec::Link(3pm) β brought to you by perl v5.40.0, dated 2025-02-07. go resolve some links, bestie, you got this πβ¨
π¦ where this page comes from
- debian trixie: libfile-copy-link-perl 0.200-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libfile-copy-link-perl 0.200-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfile-copy-link-perl 0.200-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms