File::Spec::Link(3pm)

πŸ“¦
version 0.200 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

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 $link is linked to. how? by readlinking $link, and then resolving that path relative to the directory that $link lives in. slay πŸŽ€
  • resolve($link) β€” gives you the non-link that $link ultimately points at, by repeatedly calling linked over and over until it stops being a link. if the link can't be resolved at all? you get undef. no cap, that's just how it is 😭
  • chopfile($file) β€” returns the directory of $file, by splitting the path of $file and 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 $path relative to the directory of the file $file. but if $path is absolute? it just returns $path. periodt.
  • resolve_all($file) β€” returns the filename of $file with all the links in the path resolved, wihout using Cwd. (again, her spelling, her rules πŸ’œ)
  • full_resolve($file) β€” returns the filename of $file with all the links in the path resolved. this sub tries to use Cwd::abs_path via ->resolve_path. ✨
  • resolve_path($file) β€” returns the filename of $file with all the links in the path resolved. this sub uses Cwd::abs_path and is independent of the rest of File::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, using catpath
  • canonical β€” returns the canonical path, using canonpath
  • vol β€” returns the volume element of the path, see File::Spec->splitpath
  • dir β€” returns the directory element of the path, as a string, see File::Spec->splitpath
  • dirs β€” return the list of directory components in the path, see File::Spec->splitdir
  • pop β€” remove the 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
  • split($path) β€” populate a path object, using splitpath
  • chop β€” 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 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 ⭐

πŸ’€ Other class methods πŸ’€

  • canonpath($path) β€” a wrapper round File::Spec::canonpath, and it goes fatal if the input is empty. so don't do that bestie.
  • catdir(@dirs) β€” a wrapper round File::Spec::catdir, returns curdir from an empty list πŸ“
  • splitlast($path) β€” get a component from $path (using chop) 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 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