SPVM-Sys
view release on metacpan or search on metacpan
lib/SPVM/Sys.spvm view on Meta::CPAN
}
static method unlink : void ($file : string) {
if (Sys::OS->is_windows) {
Sys::IO::Windows->unlink($file);
}
else {
Sys::IO->unlink($file);
}
}
static method rename : void ($old_path : string, $new_path : string) {
if (Sys::OS->is_windows) {
Sys::IO::Windows->rename($old_path, $new_path);
}
else {
Sys::IO->rename($old_path, $new_path);
}
}
static method symlink : int ($old_path : string, $new_path : string) {
if (Sys::OS->is_windows) {
Sys::IO::Windows->symlink($old_path, $new_path);
}
else {
Sys::IO->symlink($old_path, $new_path);
}
my $success = 1;
return $success;
}
static method readlink : string ($file : string) {
my $stat = Sys->lstat($file);
my $readlink_buffer_size = (int)$stat->st_size;
my $buffer = (mutable string)new_string_len $readlink_buffer_size;
if (Sys::OS->is_windows) {
Sys::IO::Windows->readlink($file, $buffer, $readlink_buffer_size);
}
else {
Sys::IO->readlink($file, $buffer, $readlink_buffer_size);
}
return $buffer;
}
static method chdir : void ($dir : string) {
Sys::IO->chdir($dir);
}
static method chmod : void ($mode :int, $file : string) {
Sys::IO->chmod($file, $mode);
}
static method chown : void ($owner : int, $group : int, $file : string) {
Sys::IO->chown($file, $owner, $group);
}
static method opendir : void ($dir_stream_ref : Sys::IO::DirStream[], $dir : string) {
my $dh = Sys::IO->opendir($dir);
$dir_stream_ref->[0] = $dh;
}
static method closedir : void ($dir_stream : Sys::IO::DirStream) {
unless ($dir_stream) {
die "The directory stream \$dir_stream must be defined.";
}
if ($dir_stream->closed) {
die "The directory stream \$dir_stream is already closed.";
}
Sys::IO->closedir($dir_stream);
}
static method readdir : Sys::IO::Dirent ($dir_stream : Sys::IO::DirStream) {
unless ($dir_stream) {
die "The directory stream \$dir_stream must be defined.";
}
if ($dir_stream->closed) {
die "The directory stream \$dir_stream is already closed.";
}
my $dirent = Sys::IO->readdir($dir_stream);
return $dirent;
}
static method rewinddir : void ($dir_stream : Sys::IO::DirStream) {
unless ($dir_stream) {
die "The directory stream \$dir_stream must be defined.";
}
if ($dir_stream->closed) {
die "The directory stream \$dir_stream is already closed.";
}
Sys::IO->rewinddir($dir_stream);
}
static method seekdir : void ($dir_stream : Sys::IO::DirStream, $offset : long) {
unless ($dir_stream) {
die "The directory stream \$dir_stream must be defined.";
}
if ($dir_stream->closed) {
die "The directory stream \$dir_stream is already closed.";
}
( run in 0.690 second using v1.01-cache-2.11-cpan-5511b514fd6 )