Sidef
view release on metacpan or search on metacpan
lib/Sidef/Types/Glob/File.pm view on Meta::CPAN
*open_write = \&open_w;
sub open_a {
ref($_[0]) || shift(@_);
my ($self, @args) = @_;
Sidef::Types::Glob::File::open($self, '>>:utf8', @args);
}
*open_append = \&open_a;
sub open_rw {
ref($_[0]) || shift(@_);
my ($self, @args) = @_;
Sidef::Types::Glob::File::open($self, '+<:utf8', @args);
}
*open_read_write = \&open_rw;
sub open_arw {
ref($_[0]) || shift(@_);
my ($self, @args) = @_;
Sidef::Types::Glob::File::open($self, '+>>:utf8', @args);
}
*open_append_read_write = \&open_arw;
sub opendir {
ref($_[0]) || shift(@_);
my ($self, @args) = @_;
Sidef::Types::Glob::Dir->new("$self")->open(@args);
}
sub sysopen {
ref($_[0]) || shift(@_);
my ($self, $var_ref, $mode, $perm) = @_;
my $success = sysopen(my $fh, "$self", "$mode", $perm // 0666);
if ($success) {
$$var_ref = Sidef::Types::Glob::FileHandle->new($fh, $self);
}
$success
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}
sub stat {
ref($_[0]) || shift(@_);
my ($self) = @_;
Sidef::Types::Glob::Stat->stat("$self", $self);
}
sub lstat {
ref($_[0]) || shift(@_);
my ($self) = @_;
Sidef::Types::Glob::Stat->lstat("$self", $self);
}
sub chown {
ref($_[0]) || shift(@_);
my ($self, $uid, $gid) = @_;
CORE::chown($uid, $gid, "$self")
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}
sub chmod {
ref($_[0]) || shift(@_);
my ($self, $permission) = @_;
CORE::chmod($permission, "$self")
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}
sub utime {
ref($_[0]) || shift(@_);
my ($self, $atime, $mtime) = @_;
CORE::utime($atime, $mtime, "$self")
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}
sub truncate {
ref($_[0]) || shift(@_);
my ($self, $length) = @_;
CORE::truncate("$self", $length // 0)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}
sub unlink {
my ($self, @args) = @_;
if (ref($self)) {
CORE::unlink("$self")
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}
else {
Sidef::Types::Number::Number::_set_int(CORE::unlink(@args));
}
}
sub delete {
my ($self, @args) = @_;
if (ref($self)) {
my $file = "$self";
CORE::unlink($file) || return Sidef::Types::Bool::Bool::FALSE;
1 while CORE::unlink($file);
return Sidef::Types::Bool::Bool::TRUE;
}
else {
my $count = 0;
foreach my $arg (@args) {
my $file = "$arg";
CORE::unlink($file) || next;
1 while CORE::unlink($file);
++$count;
}
( run in 0.664 second using v1.01-cache-2.11-cpan-5511b514fd6 )