LaTeXML...Pathname(3)

πŸ“¦ version 0.8.8, in nixos 26.05, nixpkgs unstable

🌸 NAME 🌸

okay bestie, meet LaTeXML::Util::Pathname β€” portable pathname and file-system utilities πŸ’…. It's part of the User Contributed Perl Documentation crew, and it's here to make path stuff feel a little less chaotic ✨


πŸ’– DESCRIPTION πŸ’–

lowkey iconic: this module combines the functionality File::Spec and File::Basename to give a consistent set of filename utilities for LaTeXML. A pathname is represented by a simple string. periodt 🫢

🧚 Pathname Manipulations 🧚

  • $path = pathname_make(%peices); β€” constructs a pathname from the keywords in pieces πŸ’–:
    • dir : directory
    • name : the filename (possibly with extension)
    • type : the filename extension
  • ($dir,$name,$type) = pathname_split($path); β€” splits pathname $path into the components: directory, name and type. clean split, no crumbs ✨
  • $path = pathname_canonical($path); β€” canonicalizes pathname $path by simplifying repeated slashes, dots representing current or parent directory, etc. so tidy πŸŽ€
  • $dir = pathname_directory($path); β€” returns the directory component of pathname $path. that folder bit πŸ“
  • $name = pathname_name($path); β€” returns the name component of pathname $path. that filename bit 🏷️
  • $type = pathname_type($path); β€” returns the type component of pathname $path. that extension bit πŸ‘
  • $path = pathname_concat($dir,$file); β€” returns the pathname resulting from concatenating directory $dir and filename $file. glue those bits together 🫢
  • $boole = pathname_is_absolute($path); β€” returns whether pathname $path appears to be an absolute pathname. absolute vibes check ⭐
  • $boole = pathname_is_url($path); β€” returns whether pathname $path appears to be a url, rather than local file. url or local? iykyk 🌐
  • $boole = pathname_is_literaldata($path); β€” returns whether pathname $path is actually a blob of literal data, with a leading "literal:" protocol. literal data moment 🧚
  • $boole = pathname_is_raw($path); β€” check if pathname indicates a raw TeX source or definition file. raw TeX realness πŸ”₯
  • $rel = pathname_is_contained($path,$base); β€” checks whether $path is underneath the directory $base; if so it returns the pathname $path relative to $base; otherwise returns undef. contained or not contained, that is the question πŸ¦‹
  • $path = pathname_relative($path,$base); β€” if $path is an absolute, non-URL pathname, returns the pathname relative to the directory $base, otherwise simply returns the canonical form of $path. relative realness 🌈
  • $path = pathname_absolute($path,$base); β€” returns the absolute pathname resulting from interpreting $path relative to the directory $base. If $path is already absolute, it is returned unchanged. absolute and unbothered πŸ‘‘
  • $relative_url = pathname_to_url($path); β€” creates a local, relative URL for a given pathname, also ensuring proper path separators on non-Unix systems. url-ify it, bestie πŸ’…

πŸ¦‹ File System Operations πŸ¦‹

  • $modtime = pathname_timestamp($path); β€” returns the modification time of the file named by $path, or undef if the file does not exist. timestamp check ⏰
  • $path = pathname_cwd(); β€” returns the current working directory. where are we? iconic πŸ“
  • $dir = pathname_mkdir($dir); β€” creates the directory $dir and all missing ancestors. It returns $dir if successful, else undef. make the whole directory tree happen 🌱
  • $dest = pathname_copy($source,$dest); β€” copies the file $source to $dest if needed; ie. if $dest is missing or older than $source. It preserves the timestamp of $source. copy with timestamp preservation πŸ“
  • $path = pathname_find($name,%options); β€” finds the first file named $name that exists and that matches the specification in the keywords %options. An absolute pathname is returned. the search begins πŸ”Ž
    • If $name is not already an absolute pathname, then the option paths determines directories to recursively search. It should be a list of pathnames, any relative paths are interpreted relative to the current directory. If paths is omitted, then the current directory is searched.
    • If the option installation_subdir is given, it indicates, in addition to the above, a directory relative to the LaTeXML installation directory to search. This allows files included with the distribution to be found.
    • The types option specifies a list of filetypes to search for. If not supplied, then the filename must match exactly. The type * matches any extension.
  • @paths = pathname_findall($name,%options); β€” like pathname_find, but returns all matching (absolute) paths that exist. collect all the matches, no crumbs left behind πŸ’–
  • $path = pathname_kpsewhich(@names); β€” attempt to find a candidate name via the external kpsewhich capability of the system's TeX toolchain. If kpsewhich is not available, or the file is not found, returns a Perl undefined value. kpsewhich said what it said 🧚

πŸ‘‘ AUTHOR πŸ‘‘

Bruce Miller β€” bruce.miller@nist.gov πŸ’Œ

Public domain software, produced as part of work done by the United States Government & not subject to copyright in the US.


πŸ’– that’s the tea, bestie β€” this page comes from perl v5.42.3, dated 2024-02-26, under the page tag LaTeXML...Pathname(3). go forth and pathname slay πŸ’…βœ¨

πŸ“¦ where this page comes from