- STATIC FUNCTIONS
App::hopen::Util::BasedPath - A path relative to a specified base
BasedPath represents a path to a file or directory, plus a directory with respect to which that path is defined. That means you can rebase the file or dir while retaining the relative path. Usage example:
my $based = based_path(path => file('foo'), base => dir('bar')); $based->orig; # Path::Class::File for bar/foo $based->path_on(dir('quux')); # Path::Class::File for quux/foo
The path, as a Path::Class::File or Path::Class::Dir instance. May not be specified as a string when creating a new object, since there's no reliable way to tell whether a file or directory would be intended.
This must be a relative path, since the whole point of this module is to combine partial paths!
A Path::Class::Dir to which the "path" is relative. May be specified as a string for convenience; however,
'' (the empty string) is forbidden (to avoid confusion). Use
dir() for the current directory or
dir('') for the root directory.
The working directory at the time the BasedPath instance was created. This is an absolute path.
Path::Class::* representing the relative path from a given directory to the original location. (
wrt = With Respect To) Example:
# In directory "project" my $based = based_path(path => file('foo'), base => dir('bar')); $based->orig; # Path::Class::File for bar/foo $based->path_wrt('..'); # Path::Class::File for project/bar/foo
my $new_path = $based_path->path_on($new_base);
This is in some ways the opposite of
# in directory 'dir' my $file = file('foo.txt'); # The foo.txt in dir/ say $file->relative('..'); # "dir/foo.txt" - same file, but # accessed from "..". my $based = based_path(path=>file('foo.txt'), base=>''); # Name foo.txt, based off dir say $based->path_on(dir('..')); # dir/../foo.txt - a different file
Stringify the instance in a way that is human-readable, but NOT suitable for machine consumption.
Sanity-check the arguments.
A synonym for
App::hopen::Util::BasedPath->new(). Exported by default.