The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

SPVM::Sys::IO::Stat - struct stat in the C language

Description

The Sys::IO::Stat class in SPVM represents struct stat in the C language, and has utility methods for the structure.

Usage

  use Sys::IO::Stat;
  
  my $file = "foo.txt";
  my $stat = Sys::IO::Stat->new;
  
  Sys::IO::Stat->stat($file, $stat);
  
  Sys::IO::Stat->lstat($file, $stat);
  
  my $st_mode = $stat->st_mode;
  my $st_size = $stat->st_size;

Details

This class is a pointer class. The pointer the instance has is set to a struct stat object.

Class Methods

new

static method new : Sys::IO::Stat ();

Creates a new Sys::IO::Stat object.

stat

static method stat : int ($path : string, $stat : Sys::IO::Stat);

Calls the stat function and returns its return value.

Exceptions:

$path must be defined. Otherwise an exception is thrown.

$stat must be defined. Otherwise an exception is thrown.

If the stat function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.

lstat

static method lstat : int ($path : string, $stat : Sys::IO::Stat);

Calls the lstat function and returns its return value.

Exceptions:

$path must be defined. Otherwise an exception is thrown.

$stat must be defined. Otherwise an exception is thrown.

If the lstat function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.

fstat

static method fstat : int ($fd : int, $stat : Sys::IO::Stat);

Calls the fstat function and returns its return value.

Exceptions:

The $stat is a Sys::IO::Stat object.

$stat must be defined. Otherwise an exception is thrown.

If the stat function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.

Instance Methods

DESTROY

method DESTROY : void ();

The destructor.

st_dev

method st_dev : int ();

Returns st_dev.

st_ino

method st_ino : int ();

Returns st_ino.

st_mode

method st_mode : int ();

Returns st_mode.

method st_nlink : int ();

Returns st_nlink.

st_uid

method st_uid : int ();

Returns st_uid.

st_gid

method st_gid : int ();

Returns st_gid.

st_rdev

method st_rdev : int ();

Returns st_rdev.

st_size

method st_size : long ();

Returns st_size.

st_blksize

method st_blksize : long ();

Returns st_blksize.

st_blocks

method st_blocks : long ();

Returns st_blocks.

st_mtime

method st_mtime : long ();

Returns st_mtime.

st_atime

method st_atime : long ();

Returns st_atime.

st_ctime

method st_ctime : long ();

Returns st_ctime.

st_mtim_tv_nsec

method st_mtim_tv_nsec : long ();

Returns st_mtim.tv_nsec.

st_atim_tv_nsec

method st_atim_tv_nsec : long ();

Returns st_atim.tv_nsec.

st_ctim_tv_nsec

method st_ctim_tv_nsec : long ();

Returns st_ctim.tv_nsec.

A

method A : double ();

The implementation of the A method in the Sys class.

C

method C : double ();

The implementation of the C method in the Sys class.

M

method M : double ();

The implementation of the M method in the Sys class.

O

method O : int ();

The implementation of the O method in the Sys class.

S

method S : int ();

The implementation of the S method in the Sys class.

b

method b : int ();

The implementation of the b method in the Sys class.

c

method c : int ();

The implementation of the c method in the Sys class.

d

method d : int ();

The implementation of the d method in the Sys class.

e

method e : int ();

The implementation of the e method in the Sys class.

f

method f : int ();

The implementation of the f method in the Sys class.

g

method g : int ();

The implementation of the g method in the Sys class.

k

method k : int ();

The implementation of the k method in the Sys class.

l

method l : int ();

The implementation of the l method in the Sys class.

o

method o : int ();

The implementation of the o method in the Sys class.

p

method p : int ();

The implementation of the p method in the Sys class.

s

method s : long ();

The implementation of the s method in the Sys class.

u

method u : int ();

The implementation of the u method in the Sys class.

z

method z : int ();

The implementation of the z method in the Sys class.

r

method r : int ();

The implementation of the r method in the Sys class.

w

method w : int ();

The implementation of the w method in the Sys class.

x

method x : int ();

The implementation of the x method in the Sys class.

R

method R : int ();

The implementation of the R method in the Sys class.

W

method W : int ();

The implementation of the W method in the Sys class.

X

method X : int ();

The implementation of the X method in the Sys class.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License