--- name: File::Spec runtime: pp source: src/native/File/Spec/pp.rs --- ```{index} single: File::Spec; Perl module (pp runtime) ``` # File::Spec Native implementation of File::Spec Provides portable file path operations using Unix semantics. # Synopsis use File::Spec; my $path = File::Spec->catfile("usr", "local", "bin", "perl"); my $dir = File::Spec->catdir("usr", "local", "lib"); my ($vol, $dirs, $file) = File::Spec->splitpath($path); my @dirs = File::Spec->splitdir($dirs); my $abs = File::Spec->rel2abs("lib/Foo.pm"); my $rel = File::Spec->abs2rel("/usr/local/bin", "/usr"); # Functions ## canonpath Clean up a path by removing redundant separators and up-level references. ```perl use File::Spec; my $clean = File::Spec->canonpath("/foo//bar/../baz"); # "/foo/baz" ``` ## catdir Concatenate directory names to form a complete path. ```perl use File::Spec; my $dir = File::Spec->catdir("/usr", "local", "bin"); # "/usr/local/bin" ``` ## catfile Concatenate directory names and a filename to form a complete path. ```perl use File::Spec; my $file = File::Spec->catfile("/usr", "local", "bin", "perl"); ``` ## curdir Return a string representation of the current directory ("."). ## updir Return a string representation of the parent directory (".."). ## rootdir Return a string representation of the root directory ("/"). ## devnull Return the path to the null device ("/dev/null"). ## tmpdir Return the path to the system temporary directory (from $TMPDIR, $TEMP, $TMP, or "/tmp"). ## splitdir Split a directory path into its component parts. ```perl use File::Spec; my @dirs = File::Spec->splitdir("/usr/local/bin"); # ("", "usr", "local", "bin") ``` ## splitpath Split a path into volume, directory, and filename components. ```perl use File::Spec; my ($vol, $dir, $file) = File::Spec->splitpath("/usr/local/bin/perl"); ``` ## catpath Combine volume, directory, and filename into a complete path (inverse of splitpath). ## file_name_is_absolute Return true if the given path is absolute (starts with "/"). ## path Return the list of directories in the PATH environment variable. ## rel2abs Convert a relative path to an absolute path, optionally relative to a given base. ```perl use File::Spec; my $abs = File::Spec->rel2abs("lib/Foo.pm"); ``` ## abs2rel Return a relative path from the base to the given path. ```perl use File::Spec; my $rel = File::Spec->abs2rel("/usr/local/bin", "/usr"); # "local/bin" ``` ## no_upwards Filter out "." and ".." entries from a list of directory names. ## case_tolerant Return false (0) on Unix, where the filesystem is case-sensitive. ## join Alias for catfile. Concatenate path components into a complete path. Perl equivalent: File::Spec, File::Spec::Unix, File::Spec::Functions