How do we work with OS-independent paths in Perl 6?

I'm trying this on Windows 7 (one of the OSes you seem to be mostly interested in according to tags), using

This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03
implementing Perl 6.d.

And it seems to work just like that

> with mkdir IO::Path.new('a/b/c') { say .e; say .absolute }
True
C:\rakudo\a\b\c

The directory is indeed created properly.

Note that IO::Path takes an IO::Spec object defaulting to $*SPEC in its constructor, so the necessary OS-dependent part is available to the object. In Rakudo the IO::Spec is indeed used by mkdir through .absolute. There also is a roast test about / in an IO::Path becoming \ on Windows.

As Elizabeth Mattijsen pointed out, Windows seems to just support forward slashes by itself. Others claim that this has been the case forever:

Actually, every version of Windows, and every version of MS-DOS from 2.0 on, has accepted "/" as a path delimiter.


On a Windows 10 Enterprise VM:

C:\Users\me>c:/rakudo/bin/perl6 -e "mkdir IO::Path.new( 'a/b/c' )"

C:\Users\me>tree a
Folder PATH listing
Volume serial number is xxx
C:\USERS\ME\A
└───b
    └───c

Tags:

Windows

Raku