How to resolve the algorithm File modification time step by step in the Raku programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm File modification time step by step in the Raku programming language

Table of Contents

Problem Statement

Get and set the modification time of a file.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm File modification time step by step in the Raku programming language

Source code in the raku programming language

use NativeCall;

class utimbuf is repr('CStruct') {
    has int $.actime;
    has int $.modtime;

    submethod BUILD(:$atime, :$mtime) {
        $!actime = $atime;
        $!modtime = $mtime.to-posix[0].round;
    }
}

sub sysutime(Str, utimbuf --> int32) is native is symbol('utime') {*}

sub MAIN (Str $file) {
    my $mtime = $file.IO.modified orelse .die;

    my $ubuff = utimbuf.new(:atime(time),:mtime($mtime));

    sysutime($file, $ubuff);
}


  

You may also check:How to resolve the algorithm Cholesky decomposition step by step in the Maple programming language
You may also check:How to resolve the algorithm Naming conventions step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Greatest common divisor step by step in the MINIL programming language
You may also check:How to resolve the algorithm Call a function step by step in the OCaml programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the ColdFusion programming language