SPVM::Sys::IO - IO System Call
use Sys::IO;
Sys::IO is the class for the file IO.
Sys::IO
static method stdin : Sys::IO::FileStream ();
Returns stdin.
static method stdout : Sys::IO::FileStream ();
Returns stdout.
static method stderr : Sys::IO::FileStream ();
Returns stderr.
static method spvm_stdin : Sys::IO::FileStream ();
Returns the stdin opened by the SPVM language.
static method spvm_stdout : Sys::IO::FileStream ();
Returns the stdout opened by the SPVM language.
static method spvm_stderr : Sys::IO::FileStream ();
Returns the stderr opened by the SPVM language.
static method fopen : Sys::IO::FileStream ($path : string, $mode : string);
Calls the fopen function and returns its return value.
Exceptions:
$path must be defined. Otherwise an exception is thrown.
$mode must be defined. Otherwise an exception is thrown.
If the fopen function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
eval_error_id
static method fdopen : Sys::IO::FileStream ($fd : int, $mode : string);
Calls the fdopen function and returns its return value.
$fd must be greater than or equal to 0. Otherwise an exception is thrown.
If the fdopen function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method fileno : int ($stream : Sys::IO::FileStream);
Calls the fileno function and returns its return value.
$stream must be defined. Otherwise an exception is thrown.
If the fileno function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method fread : int ($ptr : mutable string, $size : int, $nmemb : int, $stream : Sys::IO::FileStream, $ptr_offset : int = 0);
Calls the fread function and returns its return value.
$ptr must be defined. Otherwise an exception is thrown.
$size must be more than or equal to 0. Otherwise an exception is thrown.
$nmemb must be more than or equal to 0. Otherwise an exception is thrown.
$nmemb * $size must be less than or equal to the length of $ptr - $ptr_offset. Otherwise an exception is thrown.
If the return value is less than $nmemb and ferror(stream) is non-zero, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
ferror(stream)
static method feof : int ($stream : Sys::IO::FileStream);
Calls the feof function and returns its return value.
static method ferror : int ($stream : Sys::IO::FileStream);
Calls the ferror function and returns its return value.
static method clearerr : void ($stream : Sys::IO::FileStream);
Calls the clearerr function.
static method getc : int ($stream : Sys::IO::FileStream);
Calls the getc function and returns its return value.
If the return value is EOF and ferror(stream) is non-zero, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
EOF
static method ungetc : int ($c : int, $stream : Sys::IO::FileStream);
Calls the ungetc function and returns its return value.
If the return value is EOF and ferror(stream) is non-zero, an exception is thrown.
static method fgets : mutable string ($s : mutable string, $size : int, $stream : Sys::IO::FileStream, $s_offset : int = 0);
Calls the fgets function and returns its return value.
$s must be defined. Otherwise an exception is thrown.
$size must be less than the length of $s - $s_offset. Otherwise an exception is thrown.
static method fwrite : int ($ptr : string, $size : int, $nmemb : int, $stream : Sys::IO::FileStream, $ptr_offset : int = 0);
Calls the fwrite function and returns its return value.
static method fclose : int ($stream : Sys::IO::FileStream);
Calls the fclose function and returns its return value.
If successful, the closed field is set to 1.
$stream must be defined
If the fclose function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method fseek : int ($stream : Sys::IO::FileStream, $offset : long, $whence : int);
Calls the fseek function and returns its return value.
See Sys::IO::Constant about constant values given to $whence.
$offset must be greater than or equal to 0. Otherwise an exception is thrown.
If the fseek function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method ftell : long ($stream : Sys::IO::FileStream);
Calls the ftell function and returns its return value.
If the ftell function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method fflush : int ($stream : Sys::IO::FileStream);
Calls the fflush function and returns its return value.
If the fflush function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method freopen : Sys::IO::FileStream ($path : string, $mode : string, $stream : Sys::IO::FileStream);
Calls the freopen function and returns its return value.
If the freopen function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method setvbuf : int ($stream : Sys::IO::FileStream, $buf : mutable string, $mode : int, $size : int);
Calls the setvbuf function and returns its return value.
See Sys::IO::Constant about constant values given to $mode.
If $buf is defined, $size must be greater than or equal to 0. Otherwise an exception is thrown.
If $buf is defined, $size must be less than or equal to the length of $buf. Otherwise an exception is thrown.
If the setvbuf function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method setbuf : void ($stream : Sys::IO::FileStream, $buf : mutable string);
Calls the "setvbuf" method given the following mode $mode and size $size.
If $buf is defined, $mode is set to _IOFBF, otherwise _IONBF.
_IOFBF
_IONBF
$size is BUFSIZ.
BUFSIZ
static method setbuffer : void ($stream : Sys::IO::FileStream, $buf : mutable string, $size : int);
Calls the "setvbuf" method given the following mode $mode.
static method setlinebuf : void ($stream : Sys::IO::FileStream);
Calls the "setvbuf" method given the following buffer $buf and mode $mode.
$buf is undef.
$mode is _IOLBF.
_IOLBF
static method open : int ($path : string, $flags : int, $mode : int = 0);
Calls the open function and returns its return value.
See Sys::IO::Constant about constant values given to the flags $flags and the mode $mode.
If the open function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method read : int ($fd : int, $buf : mutable string, $count : int, $buf_offset : int = 0);
Calls the read function and returns its return value.
$buf must be defined. Otherwise an exception is thrown.
$count must be more than or equal to 0. Otherwise an exception is thrown.
$count must be less than the length of $buf - $buf_offset. Otherwise an exception is thrown.
If the read function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method write : int ($fd : int, $buf : string, $count : int, $buf_offset : int = 0);
Calls the write function and returns its return value.
$buf_offse must be greater than or equal to 0. Otherwise an exception is thrown.
If the write function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method lseek : long ($fd : int, $offset : long, $whence : int);
Calls the lseek function and returns its return value.
If the lseek function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method close : int ($fd : int);
Calls the close function and returns its return value.
If the close function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method fsync : int ($fd : int);
Calls the fsync function and returns its return value.
If the fsync function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method fcntl : int ($fd : int, $command : int, $command_arg : object of Int|SPVM::Sys::IO::Flock = undef);
Calls the fcntl function and returns its return value.
$command_arg must be an instance of the Int class or Sys::IO::Flock class.
static method ftruncate : int ($fd : int, $length : long);
Calls the ftruncate function and returns its return value.
If the ftruncate function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method flock : int ($fd : int, $operation : int);
Calls the flock function and returns its return value.
See Sys::IO::Constant about constant values given to the operation $operation.
If the flock function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method access : int ($pathname : string, $mode : int);
Calls the access function and returns its return value.
See Sys::IO::Constant about constant values given to the mode $mode.
$pathname must be defined. Otherwise an exception is thrown.
If the access function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method faccessat : int ($dirfd : int, $pathname : string, $mode : int, $flags : int);
Calls the faccessat function and returns its return value.
See Sys::IO::Constant about constant values given to the mode $mode and the flag $flag.
If the faccessat function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method eaccess : int ($pathname : string, $mode : int);
Calls the "faccessat" method given the following $dirfd and $flag.
$dirfd is AT_FDCWD.
AT_FDCWD
$flag is AT_EACCESS.
AT_EACCESS
static method truncate : int ($path : string, $length : long);
Calls the truncate function and returns its return value.
$length must be less than or equal to 0.
If the truncate function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method mkdir : int ($path : string, $mode : int);
Windows:
Calls the _mkdir function and return its return value.
OS other than Windows:
Calls the mkdir function and return its return value.
If the mkdir(or _mkdir) function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method umask : int ($mode : int);
Calls the umask function and return its return value.
static method rmdir : int ($path : string);
Calls the rmdir function and return its return value.
If the rmdir function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method unlink : int ($pathname : string);
Calls the unlink function and return its return value.
If the unlink function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method rename : int ($oldpath : string, $newpath : string);
Calls the rename function and return its return value.
$oldpath must be defined. Otherwise an exception is thrown.
$newpath must be defined. Otherwise an exception is thrown.
If the rename function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method getcwd : mutable string ($buf : mutable string, $size : int);
Calls the getcwd function and return its return value.
$size must be greater than or equal to 0. Otherwise an exception is thrown.
If the getcwd function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method _getdcwd : mutable string ($drive : int, $buffer : mutable string, $maxlen : int);
Calls the _getdcwd function and return its return value.
$maxlen must be greater than 0. Otherwise an exception is thrown.
$maxlen must be less than or equal to the lenght of $buffer. Otherwise an exception is thrown.
If the _getdcwd function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method realpath : mutable string ($path : string, $resolved_path : mutable string);
Calls the realpath function and return its return value.
If the realpath function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
native static method _fullpath : mutable string ($absPath : mutable string, $relPath : string, $maxLength : int);
Calls the _fullpath function and return its return value.
$relPath must be defined. Otherwise an exception is thrown.
If the _fullpath function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method chdir : int ($path : string);
Calls the chdir function and return its return value.
If the chdir function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method chmod : int ($path : string, $mode :int);
Calls the chmod function and return its return value.
If the chmod function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method chown : int ($path : string, $owner : int, $group : int);
Calls the chown and return its return value.
If the chown function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method symlink : int ($oldpath : string, $newpath : string);
Calls the symlink function and return its return value.
If the symlink function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method readlink : int ($path : string, $buf : mutable string, $bufsiz : int);
Calls the readlink function and return its return value.
$bufsiz must be greater than or equal to 0. Otherwise an exception is thrown.
$bufsiz must be less than or equal to the length of $buf. Otherwise an exception is thrown.
If the readlink function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method opendir : Sys::IO::DirStream ($dir : string);
Calls the opendir function and return its return value.
$dir must be defined. Otherwise an exception is thrown.
If the opendir function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method closedir : int ($dirp : Sys::IO::DirStream);
Calls the closedir function and return its return value.
$dirp must be defined. Otherwise an exception is thrown.
If the closedir function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method readdir : Sys::IO::Dirent ($dirp : Sys::IO::DirStream);
Calls the readdir function and return its return value.
If the readdir function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method rewinddir : void ($dirp : Sys::IO::DirStream);
Calls the rewinddir function.
static method telldir : long ($dirp : Sys::IO::DirStream);
Calls the telldir function and return its return value.
If the telldir function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method seekdir : void ($dirp : Sys::IO::DirStream, $offset : long);
Calls the seekdir function and return its return value.
$offset must be less than or equal to 0.
static method popen : Sys::IO::FileStream ($command : string, $type : string);
Calls the popen function and returns its return value.
The is_pipe field in the Sys::IO::FileStream class is set to 1.
$command must be defined. Otherwise an exception is thrown.
$type must be defined. Otherwise an exception is thrown.
If the popen function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method _popen : Sys::IO::FileStream ($command : string, $type : string);
Calls the _popen function and returns its return value.
If the _popen function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method pclose : int ($stream : Sys::IO::FileStream);
Calls the pclose function and returns its return value.
If the pclose function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
static method _pclose : int ($stream : Sys::IO::FileStream);
Calls the _pclose function and returns its return value.
If the _pclose function failed, an exception is thrown with eval_error_id set to the basic type ID of the Error::System class.
Copyright (c) 2023 Yuki Kimoto
MIT License
To install SPVM::Sys, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM::Sys
CPAN shell
perl -MCPAN -e shell install SPVM::Sys
For more information on module installation, please visit the detailed CPAN module installation guide.