Documentation for routine is-absolute

Documentation for routine is-absolute, assembled from the following types:

class IO::Path

From IO::Path

(IO::Path) method is-absolute

Defined as:

method is-absolute(IO::Path:D: --> Bool)

Returns True if the path is an absolute path, and False otherwise.

"/foo".IO.is-absolute.say# OUTPUT: «True␤» 
"bars".IO.is-absolute.say# OUTPUT: «False␤» 

Note that on Windows a path that starts with a slash or backslash is still considered absolute even if no volume was given, as it is absolute for that particular volume:

IO::Path::Win32.new("/foo"  ).is-absolute.say# OUTPUT: «True␤» 
IO::Path::Win32.new("C:/foo").is-absolute.say# OUTPUT: «True␤» 
IO::Path::Win32.new("C:foo" ).is-absolute.say# OUTPUT: «False␤» 

class IO::Spec::Unix

From IO::Spec::Unix

(IO::Spec::Unix) method is-absolute

Defined as:

method is-absolute(Str:D $path --> Bool:D)

Returns True if the $path starts with a slash ("/"), even if it has combining character on it:

say IO::Spec::Unix.is-absolute: "/foo";        # OUTPUT: «True␤» 
say IO::Spec::Unix.is-absolute: "/\x[308]foo"# OUTPUT: «True␤» 
say IO::Spec::Unix.is-absolute: "bar";         # OUTPUT: «False␤» 

class IO::Spec::Cygwin

From IO::Spec::Cygwin

(IO::Spec::Cygwin) method is-absolute

Defined as:

method is-absolute(Str:D $path --> Bool:D)

Returns True if the $path starts with a slash ("/") or backslash ("\"), even if they have combining character on them, optionally preceded by a volume:

say IO::Spec::Cygwin.is-absolute: "/foo";        # OUTPUT: «True␤» 
say IO::Spec::Cygwin.is-absolute: "/\x[308]foo"# OUTPUT: «True␤» 
say IO::Spec::Cygwin.is-absolute: C:\foo;      # OUTPUT: «True␤» 
say IO::Spec::Cygwin.is-absolute: "bar";         # OUTPUT: «False␤» 

class IO::Spec::Win32

From IO::Spec::Win32

(IO::Spec::Win32) method is-absolute

Defined as:

method is-absolute(Str:D $path --> Bool:D)

Returns True if the $path starts with a slash ("/") or backslash ("\"), even if they have combining character on them, optionally preceded by a volume:

say IO::Spec::Win32.is-absolute: "/foo";        # OUTPUT: «True␤» 
say IO::Spec::Win32.is-absolute: "/\x[308]foo"# OUTPUT: «True␤» 
say IO::Spec::Win32.is-absolute: C:\foo;      # OUTPUT: «True␤» 
say IO::Spec::Win32.is-absolute: "bar";         # OUTPUT: «False␤»