develooper Front page | perl.perl6.users | Postings from June 2018

Re: need mkdir, chown, chmod, del

Thread Previous | Thread Next
From:
ToddAndMargo
Date:
June 3, 2018 18:04
Subject:
Re: need mkdir, chown, chmod, del
Message ID:
bc20bed4-4603-9d5b-36d4-41c7e190d6cc@zoho.com
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;

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About