On 06/03/2018 10:04 AM, ToddAndMargo wrote:
Hi All,

I need the Perl6 commands for the following LINUX
commands.

mkdir      make directory
chown      change ownership
chmod      change file mode bits
del        delete file


Many thanks,
-T




Would you mind looking over my notes to see if I make any boo-boos?


Perl 6: File commands

Reference: https://docs.perl6.org/type/IO::Path


chown (change ownership):
   Not implemented; use a system call


Directory, make:
    mkdir DIRPATH, attrible
       mkdir $WorkingDir, 0o766;


Directory, remove:
    rmdir PATH
    Delete all specified ordinary files, links, or symbolic links.
    returns True (1) or False (0)

if rmdir $DirPath { say "worked } else { say "directory remove failed" };


Delete:
    unlink PATH
    Delete all specified ordinary files, links, or symbolic links.
    returns True (1) or False (0)

        if unlink $FileName { say "worked } else { say "Delete Failed" };


Directory (ls, dir):
    dir PATH
       for dir "{$WorkingDirectory}" -> $Content { say $Content };

    Note: for a recursice rmdir, use
       https://github.com/labster/p6-file-directory-tree


Exists (directory):
   DIRPATH.IO.d.Boo;
       if not $WorkingDir.IO.d.Bool { mkdir $WorkingDir, 0o766; }


Exists (file):
   FILEPATH.IO.e
if $NewFileName.IO.e { $NewFileSize = $NewFileName.IO.s; } else { return 4; }


File permission (retrieve):
    say "path/to/file".IO.mode;


File permission (set):
    PERMISSIONS."path/to/file".IO.mode;
         0o755.$FilePAth.IO.mode;
             chmod 0o755, <myfile1  myfile2>;

Size:
   FILEPATH.IO.s
       $FileSize = $CorePath.IO.s;

Reply via email to