Skip to content
Path::Util Perl 6 module is found here which can break up a path or directory into its compoments: directory, name, extension.
Other
  1. Other 100.0%
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/Path
t
META6.json
README.md

README.md

pathutil

Path::Util

Break up a file path into its components.

Usage:

use Path::Util;

my $p = Path::Util.new("d:\docs\usage.txt");
It can break-up Unix like or Dos like file paths.

say $p.getdrive; or say $p.drive; # it gets the drive letter, for Windwos only. Otherwise, it returns "".
say $p.getdir; or say $p.directory; or say $p.dir
say $p.getext; or say $p.extension
say $p.getbasename; # returns the filename without directory
say $p.getjustname; # returns the filename without directory and extension

Above also work without get.

say $p.print; # prints all components

say $p.separator; # returns the separator found in the path, it can be "" or "/" or "".

say $p.fsseparator; # returns Windows or Unix-like file separator depending where you run your script

say $p.getnumberofdirlevel; # number of levels in the directory

say $p.getdirlevel(2); # returns directory up to the second level

say $p.tocygwin(); # returns the cygwin format of a Windows path, nothing happens if it is of other kind.
e.g. /cygdrive/d/music/after.mp4

say $p.tomsys(); # returns the msysformat of a Windows path, nothing happens if it is of other kind.
e.g. /d/music/after.mp4

Also, it is possible to use them non-object oriented way.

say Path::Util.getbasename("d:\docs\usage.txt");

Extension is returned without dot. Directories are returned without ending separator.

You can’t perform that action at this time.