Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

196
database/perl/vendor/lib/IO/All/Base.pm vendored Normal file
View File

@@ -0,0 +1,196 @@
use strict; use warnings;
package IO::All::Base;
use Fcntl;
sub import {
my $class = shift;
my $flag = $_[0] || '';
my $package = caller;
no strict 'refs';
if ($flag eq '-base') {
push @{$package . "::ISA"}, $class;
*{$package . "::$_"} = \&$_
for qw'field const option chain proxy proxy_open';
}
elsif ($flag eq -mixin) {
mixin_import(scalar(caller(0)), $class, @_);
}
else {
my @flags = @_;
for my $export (@{$class . '::EXPORT'}) {
*{$package . "::$export"} = $export eq 'io'
? $class->_generate_constructor(@flags)
: \&{$class . "::$export"};
}
}
}
sub _generate_constructor {
my $class = shift;
my (@flags, %flags, $key);
for (@_) {
if (s/^-//) {
push @flags, $_;
$flags{$_} = 1;
$key = $_;
}
else {
$flags{$key} = $_ if $key;
}
}
my $constructor;
$constructor = sub {
my $self = $class->new(@_);
for (@flags) {
$self->$_($flags{$_});
}
$self->_constructor($constructor);
return $self;
}
}
sub _init {
my $self = shift;
$self->io_handle(undef);
$self->is_open(0);
return $self;
}
#===============================================================================
# Closure generating functions
#===============================================================================
sub option {
my $package = caller;
my ($field, $default) = @_;
$default ||= 0;
field("_$field", $default);
no strict 'refs';
*{"${package}::$field"} =
sub {
my $self = shift;
*$self->{"_$field"} = @_ ? shift(@_) : 1;
return $self;
};
}
sub chain {
my $package = caller;
my ($field, $default) = @_;
no strict 'refs';
*{"${package}::$field"} =
sub {
my $self = shift;
if (@_) {
*$self->{$field} = shift;
return $self;
}
return $default unless exists *$self->{$field};
return *$self->{$field};
};
}
sub field {
my $package = caller;
my ($field, $default) = @_;
no strict 'refs';
return if defined &{"${package}::$field"};
*{"${package}::$field"} =
sub {
my $self = shift;
unless (exists *$self->{$field}) {
*$self->{$field} =
ref($default) eq 'ARRAY' ? [] :
ref($default) eq 'HASH' ? {} :
$default;
}
return *$self->{$field} unless @_;
*$self->{$field} = shift;
};
}
sub const {
my $package = caller;
my ($field, $default) = @_;
no strict 'refs';
return if defined &{"${package}::$field"};
*{"${package}::$field"} = sub { $default };
}
sub proxy {
my $package = caller;
my ($proxy) = @_;
no strict 'refs';
return if defined &{"${package}::$proxy"};
*{"${package}::$proxy"} =
sub {
my $self = shift;
my @return = $self->io_handle->$proxy(@_);
$self->_error_check;
wantarray ? @return : $return[0];
};
}
sub proxy_open {
my $package = caller;
my ($proxy, @args) = @_;
no strict 'refs';
return if defined &{"${package}::$proxy"};
my $method = sub {
my $self = shift;
$self->_assert_open(@args);
my @return = $self->io_handle->$proxy(@_);
$self->_error_check;
wantarray ? @return : $return[0];
};
*{"$package\::$proxy"} =
(@args and $args[0] eq '>') ?
sub {
my $self = shift;
$self->$method(@_);
return $self;
}
: $method;
}
sub mixin_import {
my $target_class = shift;
$target_class = caller(0)
if $target_class eq 'mixin';
my $mixin_class = shift
or die "Nothing to mixin";
eval "require $mixin_class";
my $pseudo_class = CORE::join '-', $target_class, $mixin_class;
my %methods = mixin_methods($mixin_class);
no strict 'refs';
no warnings;
@{"$pseudo_class\::ISA"} = @{"$target_class\::ISA"};
@{"$target_class\::ISA"} = ($pseudo_class);
for (keys %methods) {
*{"$pseudo_class\::$_"} = $methods{$_};
}
}
sub mixin_methods {
my $mixin_class = shift;
no strict 'refs';
my %methods = all_methods($mixin_class);
map {
$methods{$_}
? ($_, \ &{"$methods{$_}\::$_"})
: ($_, \ &{"$mixin_class\::$_"})
} (keys %methods);
}
sub all_methods {
no strict 'refs';
my $class = shift;
my %methods = map {
($_, $class)
} grep {
defined &{"$class\::$_"} and not /^_/
} keys %{"$class\::"};
return (%methods);
}
1;

92
database/perl/vendor/lib/IO/All/DBM.pm vendored Normal file
View File

@@ -0,0 +1,92 @@
use strict; use warnings;
package IO::All::DBM;
use IO::All::File -base;
use Fcntl;
field _dbm_list => [];
field '_dbm_class';
field _dbm_extra => [];
sub dbm {
my $self = shift;
bless $self, __PACKAGE__;
$self->_dbm_list([@_]);
return $self;
}
sub _assert_open {
my $self = shift;
return $self->tied_file
if $self->tied_file;
$self->open;
}
sub assert_filepath {
my $self = shift;
$self->SUPER::assert_filepath(@_);
if ($self->_rdonly and not -e $self->pathname) {
my $rdwr = $self->_rdwr;
$self->assert(0)->rdwr(1)->rdonly(0)->open;
$self->close;
$self->assert(1)->rdwr($rdwr)->rdonly(1);
}
}
sub open {
my $self = shift;
$self->is_open(1);
return $self->tied_file if $self->tied_file;
$self->assert_filepath if $self->_assert;
my $dbm_list = $self->_dbm_list;
my @dbm_list = @$dbm_list ? @$dbm_list :
(qw(DB_File GDBM_File NDBM_File ODBM_File SDBM_File));
my $dbm_class;
for my $module (@dbm_list) {
(my $file = "$module.pm") =~ s{::}{/}g;
if (defined $INC{$file} || eval "eval 'use $module; 1'") {
$self->_dbm_class($module);
last;
}
}
$self->throw("No module available for IO::All DBM operation")
unless defined $self->_dbm_class;
my $mode = $self->_rdonly ? O_RDONLY : O_RDWR;
if ($self->_dbm_class eq 'DB_File::Lock') {
$self->_dbm_class->import;
my $type = eval '$DB_HASH'; die $@ if $@;
# XXX Not sure about this warning
warn "Using DB_File::Lock in IO::All without the rdonly or rdwr method\n"
if not ($self->_rdwr or $self->_rdonly);
my $flag = $self->_rdwr ? 'write' : 'read';
$mode = $self->_rdwr ? O_RDWR : O_RDONLY;
$self->_dbm_extra([$type, $flag]);
}
$mode |= O_CREAT if $mode & O_RDWR;
$self->mode($mode);
$self->perms(0666) unless defined $self->perms;
return $self->tie_dbm;
}
sub tie_dbm {
my $self = shift;
my $hash;
my $filename = $self->name;
my $db = tie %$hash, $self->_dbm_class, $filename, $self->mode, $self->perms,
@{$self->_dbm_extra}
or $self->throw("Can't open '$filename' as DBM file:\n$!");
$self->add_utf8_dbm_filter($db)
if $self->_has_utf8;
$self->tied_file($hash);
}
sub add_utf8_dbm_filter {
my $self = shift;
my $db = shift;
$db->filter_store_key(sub { utf8::encode($_) });
$db->filter_store_value(sub { utf8::encode($_) });
$db->filter_fetch_key(sub { utf8::decode($_) });
$db->filter_fetch_value(sub { utf8::decode($_) });
}
1;

21
database/perl/vendor/lib/IO/All/DBM.pod vendored Normal file
View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::DBM - DBM Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

260
database/perl/vendor/lib/IO/All/Dir.pm vendored Normal file
View File

@@ -0,0 +1,260 @@
use strict; use warnings;
package IO::All::Dir;
use Scalar::Util 'blessed';
use File::Glob 'bsd_glob';
use IO::All::Filesys -base;
use IO::All -base;
use IO::Dir;
#===============================================================================
const type => 'dir';
option 'sort' => 1;
chain filter => undef;
option 'deep';
field 'chdir_from';
#===============================================================================
sub dir {
my $self = shift;
my $had_prev = blessed($self) && $self->pathname;
bless $self, __PACKAGE__ unless $had_prev;
if (@_ && @_ > 1 || @_ && $had_prev) {
$self->name(
$self->_spec_class->catdir(
($self->pathname ? ($self->pathname) : () ),
@_,
)
)
} elsif (@_) {
$self->name($_[0])
}
return $self->_init;
}
sub dir_handle {
my $self = shift;
bless $self, __PACKAGE__;
$self->_handle(shift) if @_;
return $self->_init;
}
#===============================================================================
sub _assert_open {
my $self = shift;
return if $self->is_open;
$self->open;
}
sub open {
my $self = shift;
$self->is_open(1);
$self->_assert_dirpath($self->pathname)
if $self->pathname and $self->_assert;
my $handle = IO::Dir->new;
$self->io_handle($handle);
$handle->open($self->pathname)
or $self->throw($self->open_msg);
return $self;
}
sub open_msg {
my $self = shift;
my $name = defined $self->pathname
? " '" . $self->pathname . "'"
: '';
return qq{Can't open directory$name:\n$!};
}
sub exists { -d shift->pathname }
#===============================================================================
sub All {
my $self = shift;
$self->all(0);
}
sub all {
my $self = shift;
my $depth = @_ ? shift(@_) : $self->_deep ? 0 : 1;
my $first = not @_;
my @all;
while (my $io = $self->next) {
push @all, $io;
push(@all, $io->all($depth - 1, 1))
if $depth != 1 and $io->is_dir;
}
@all = grep {&{$self->filter}} @all
if $self->filter;
return @all unless $first and $self->_sort;
return sort {$a->pathname cmp $b->pathname} @all;
}
sub All_Dirs {
my $self = shift;
$self->all_dirs(0);
}
sub all_dirs {
my $self = shift;
grep {$_->is_dir} $self->all(@_);
}
sub All_Files {
my $self = shift;
$self->all_files(0);
}
sub all_files {
my $self = shift;
grep {$_->is_file} $self->all(@_);
}
sub All_Links {
my $self = shift;
$self->all_links(0);
}
sub all_links {
my $self = shift;
grep {$_->is_link} $self->all(@_);
}
sub chdir {
my $self = shift;
require Cwd;
$self->chdir_from(Cwd::cwd());
CORE::chdir($self->pathname);
return $self;
}
sub empty {
my $self = shift;
my $dh;
opendir($dh, $self->pathname) or die;
while (my $dir = readdir($dh)) {
return 0 unless $dir =~ /^\.{1,2}$/;
}
return 1;
}
sub mkdir {
my $self = shift;
defined($self->perms)
? (CORE::mkdir($self->pathname, $self->perms) or die "mkdir failed: $!")
: (CORE::mkdir($self->pathname) or die "mkdir failed: $!");
return $self;
}
sub mkpath {
my $self = shift;
require File::Path;
File::Path::mkpath($self->pathname, @_);
return $self;
}
sub file {
my ($self, @rest) = @_;
return $self->_constructor->()->file($self->pathname, @rest)
}
sub next {
my $self = shift;
$self->_assert_open;
my $name = $self->readdir;
return unless defined $name;
my $io = $self->_constructor->(File::Spec->catfile($self->pathname, $name));
$io->absolute if $self->is_absolute;
return $io;
}
sub readdir {
my $self = shift;
$self->_assert_open;
if (wantarray) {
my @return = grep {
not /^\.{1,2}$/
} $self->io_handle->read;
$self->close;
if ($self->_has_utf8) { utf8::decode($_) for (@return) }
return @return;
}
my $name = '.';
while ($name =~ /^\.{1,2}$/) {
$name = $self->io_handle->read;
unless (defined $name) {
$self->close;
return;
}
}
if ($self->_has_utf8) { utf8::decode($name) }
return $name;
}
sub rmdir {
my $self = shift;
rmdir $self->pathname;
}
sub rmtree {
my $self = shift;
require File::Path;
File::Path::rmtree($self->pathname, @_);
}
sub glob {
my ($self, @rest) = @_;
map {;
my $ret = $self->_constructor->($_);
$ret->absolute if $self->is_absolute;
$ret
} bsd_glob $self->_spec_class->catdir( $self->pathname, @rest );
}
sub copy {
my ($self, $new) = @_;
require File::Copy::Recursive;
File::Copy::Recursive::dircopy($self->name, $new)
or die "failed to copy $self to $new: $!";
$self->_constructor->($new)
}
sub DESTROY {
my $self = shift;
CORE::chdir($self->chdir_from)
if $self->chdir_from;
# $self->SUPER::DESTROY(@_);
}
#===============================================================================
sub _overload_table {
(
'${} dir' => '_overload_as_scalar',
'@{} dir' => '_overload_as_array',
'%{} dir' => '_overload_as_hash',
)
}
sub _overload_as_scalar {
\ $_[1];
}
sub _overload_as_array {
[ $_[1]->all ];
}
sub _overload_as_hash {
+{
map {
(my $name = $_->pathname) =~ s/.*[\/\\]//;
($name, $_);
} $_[1]->all
};
}
1;

21
database/perl/vendor/lib/IO/All/Dir.pod vendored Normal file
View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::Dir - Directory Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

267
database/perl/vendor/lib/IO/All/File.pm vendored Normal file
View File

@@ -0,0 +1,267 @@
use strict; use warnings;
package IO::All::File;
use IO::All::Filesys -base;
use IO::All -base;
use IO::File;
use File::Copy ();
#===============================================================================
const type => 'file';
field tied_file => undef;
#===============================================================================
sub file {
my $self = shift;
bless $self, __PACKAGE__;
# should we die here if $self->name is already set and there are args?
if (@_ && @_ > 1) {
$self->name( $self->_spec_class->catfile( @_ ) )
} elsif (@_) {
$self->name($_[0])
}
return $self->_init;
}
sub file_handle {
my $self = shift;
bless $self, __PACKAGE__;
$self->_handle(shift) if @_;
return $self->_init;
}
#===============================================================================
sub assert_filepath {
my $self = shift;
my $name = $self->pathname
or return;
my $directory;
(undef, $directory) = File::Spec->splitpath($self->pathname);
$self->_assert_dirpath($directory);
}
sub assert_open_backwards {
my $self = shift;
return if $self->is_open;
require File::ReadBackwards;
my $file_name = $self->pathname;
my $io_handle = File::ReadBackwards->new($file_name)
or $self->throw("Can't open $file_name for backwards:\n$!");
$self->io_handle($io_handle);
$self->is_open(1);
}
sub _assert_open {
my $self = shift;
return if $self->is_open;
$self->mode(shift) unless $self->mode;
$self->open;
}
sub assert_tied_file {
my $self = shift;
return $self->tied_file || do {
eval {require Tie::File};
$self->throw("Tie::File required for file array operations:\n$@")
if $@;
my $array_ref = do { my @array; \@array };
my $name = $self->pathname;
my @options = $self->_rdonly ? (mode => O_RDONLY) : ();
push @options, (recsep => $self->separator);
tie @$array_ref, 'Tie::File', $name, @options;
$self->throw("Can't tie 'Tie::File' to '$name':\n$!")
unless tied @$array_ref;
$self->tied_file($array_ref);
};
}
sub open {
my $self = shift;
$self->is_open(1);
$self->assert_filepath if $self->_assert;
my ($mode, $perms) = @_;
$self->mode($mode) if defined $mode;
$self->mode('<') unless defined $self->mode;
$self->perms($perms) if defined $perms;
my @args = ($self->mode);
push @args, $self->perms if defined $self->perms;
if (defined $self->pathname) {
$self->io_handle(IO::File->new);
$self->io_handle->open($self->pathname, @args)
or $self->throw($self->open_msg);
}
elsif (defined $self->_handle and
not $self->io_handle->opened
) {
# XXX Not tested
$self->io_handle->fdopen($self->_handle, @args);
}
$self->set_lock;
$self->_set_binmode;
}
sub exists { -f shift->pathname }
my %mode_msg = (
'>' => 'output',
'<' => 'input',
'>>' => 'append',
);
sub open_msg {
my $self = shift;
my $name = defined $self->pathname
? " '" . $self->pathname . "'"
: '';
my $direction = defined $mode_msg{$self->mode}
? ' for ' . $mode_msg{$self->mode}
: '';
return qq{Can't open file$name$direction:\n$!};
}
#===============================================================================
sub copy {
my ($self, $new) = @_;
File::Copy::copy($self->name, $new)
or die "failed to copy $self to $new: $!";
$self->file($new)
}
sub close {
my $self = shift;
return unless $self->is_open;
$self->is_open(0);
my $io_handle = $self->io_handle;
$self->unlock;
$self->io_handle(undef);
$self->mode(undef);
if (my $tied_file = $self->tied_file) {
if (ref($tied_file) eq 'ARRAY') {
untie @$tied_file;
}
else {
untie %$tied_file;
}
$self->tied_file(undef);
return 1;
}
$io_handle->close(@_)
if defined $io_handle;
return $self;
}
sub empty {
my $self = shift;
-z $self->pathname;
}
sub filepath {
my $self = shift;
my ($volume, $path) = $self->splitpath;
return File::Spec->catpath($volume, $path, '');
}
sub getline_backwards {
my $self = shift;
$self->assert_open_backwards;
return $self->io_handle->readline;
}
sub getlines_backwards {
my $self = shift;
my @lines;
while (defined (my $line = $self->getline_backwards)) {
push @lines, $line;
}
return @lines;
}
sub head {
my $self = shift;
my $lines = shift || 10;
my @return;
$self->close;
LINES:
while ($lines--) {
if (defined (my $l = $self->getline)) {
push @return, $l;
}
else {
last LINES;
}
}
$self->close;
return wantarray ? @return : join '', @return;
}
sub tail {
my $self = shift;
my $lines = shift || 10;
my @return;
$self->close;
while ($lines--) {
unshift @return, ($self->getline_backwards or last);
}
$self->close;
return wantarray ? @return : join '', @return;
}
sub touch {
my $self = shift;
return $self->SUPER::touch(@_)
if -e $self->pathname;
return $self if $self->is_open;
my $mode = $self->mode;
$self->mode('>>')->open->close;
$self->mode($mode);
return $self;
}
sub unlink {
my $self = shift;
unlink $self->pathname;
}
#===============================================================================
sub _overload_table {
my $self = shift;
(
$self->SUPER::_overload_table(@_),
'file > file' => '_overload_file_to_file',
'file < file' => '_overload_file_from_file',
'${} file' => '_overload_file_as_scalar',
'@{} file' => '_overload_file_as_array',
'%{} file' => '_overload_file_as_dbm',
)
}
sub _overload_file_to_file {
require File::Copy;
File::Copy::copy($_[1]->pathname, $_[2]->pathname);
$_[2];
}
sub _overload_file_from_file {
require File::Copy;
File::Copy::copy($_[2]->pathname, $_[1]->pathname);
$_[1];
}
sub _overload_file_as_array {
$_[1]->assert_tied_file;
}
sub _overload_file_as_dbm {
$_[1]->dbm
unless $_[1]->isa('IO::All::DBM');
$_[1]->_assert_open;
}
sub _overload_file_as_scalar {
my $scalar = $_[1]->scalar;
return \$scalar;
}
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::File - File Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

View File

@@ -0,0 +1,133 @@
use strict; use warnings;
package IO::All::Filesys;
use IO::All::Base -base;
use Fcntl qw(:flock);
my %spec_map = (
unix => 'Unix',
win32 => 'Win32',
vms => 'VMS',
mac => 'Mac',
os2 => 'OS2',
);
sub os {
my ($self, $type) = @_;
my ($v, $d, $f) = $self->_spec_class->splitpath($self->name);
my @d = $self->_spec_class->splitdir($d);
$self->_spec_class($spec_map{$type});
$self->name( $self->_spec_class->catfile( @d, $f ) );
return $self
}
sub exists { my $self = shift; -e $self->name }
sub filename {
my $self = shift;
my $filename;
(undef, undef, $filename) = $self->splitpath;
return $filename;
}
sub ext {
my $self = shift;
return $1 if $self->filename =~ m/\.([^\.]+)$/
}
{
no warnings 'once';
*extension = \&ext;
}
sub mimetype {
require File::MimeInfo;
return File::MimeInfo::mimetype($_[0]->filename)
}
sub is_absolute {
my $self = shift;
return *$self->{is_absolute} = shift if @_;
return *$self->{is_absolute}
if defined *$self->{is_absolute};
*$self->{is_absolute} = IO::All::is_absolute($self) ? 1 : 0;
}
sub is_executable { my $self = shift; -x $self->name }
sub is_readable { my $self = shift; -r $self->name }
sub is_writable { my $self = shift; -w $self->name }
{
no warnings 'once';
*is_writeable = \&is_writable;
}
sub pathname {
my $self = shift;
return *$self->{pathname} = shift if @_;
return *$self->{pathname} if defined *$self->{pathname};
return $self->name;
}
sub relative {
my $self = shift;
if (my $base = $_[0]) {
$self->pathname(File::Spec->abs2rel($self->pathname, $base))
} elsif ($self->is_absolute) {
$self->pathname(File::Spec->abs2rel($self->pathname))
}
$self->is_absolute(0);
return $self;
}
sub rename {
my $self = shift;
my $new = shift;
rename($self->name, "$new")
? UNIVERSAL::isa($new, 'IO::All')
? $new
: $self->_constructor->($new)
: undef;
}
sub set_lock {
my $self = shift;
return unless $self->_lock;
my $io_handle = $self->io_handle;
my $flag = $self->mode =~ /^>>?$/
? LOCK_EX
: LOCK_SH;
flock $io_handle, $flag;
}
sub stat {
my $self = shift;
return IO::All::stat($self, @_)
if $self->is_open;
CORE::stat($self->pathname);
}
sub touch {
my $self = shift;
$self->utime;
}
sub unlock {
my $self = shift;
flock $self->io_handle, LOCK_UN
if $self->_lock;
}
sub utime {
my $self = shift;
my $atime = shift;
my $mtime = shift;
$atime = time unless defined $atime;
$mtime = $atime unless defined $mtime;
utime($atime, $mtime, $self->name);
return $self;
}
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::Filesys - File System Methods Mixin for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

58
database/perl/vendor/lib/IO/All/Link.pm vendored Normal file
View File

@@ -0,0 +1,58 @@
use strict; use warnings;
package IO::All::Link;
use IO::All::File -base;
const type => 'link';
sub link {
my $self = shift;
bless $self, __PACKAGE__;
$self->name(shift) if @_;
$self->_init;
}
sub readlink {
my $self = shift;
$self->_constructor->(CORE::readlink($self->name));
}
sub symlink {
my $self = shift;
my $target = shift;
$self->assert_filepath if $self->_assert;
CORE::symlink($target, $self->pathname);
}
sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD;
(my $method = $AUTOLOAD) =~ s/.*:://;
my $target = $self->target;
unless ($target) {
$self->throw("Can't call $method on symlink");
return;
}
$target->$method(@_);
}
sub target {
my $self = shift;
return *$self->{target} if *$self->{target};
my %seen;
my $link = $self;
my $new;
while ($new = $link->readlink) {
my $type = $new->type or return;
last if $type eq 'file';
last if $type eq 'dir';
return unless $type eq 'link';
return if $seen{$new->name}++;
$link = $new;
}
*$self->{target} = $new;
}
sub exists { -l shift->pathname }
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::Link - Link Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

View File

@@ -0,0 +1,34 @@
use strict; use warnings;
package IO::All::MLDBM;
use IO::All::DBM -base;
field _serializer => 'Data::Dumper';
sub mldbm {
my $self = shift;
bless $self, __PACKAGE__;
my ($serializer) = grep { /^(Storable|Data::Dumper|FreezeThaw)$/ } @_;
$self->_serializer($serializer) if defined $serializer;
my @dbm_list = grep { not /^(Storable|Data::Dumper|FreezeThaw)$/ } @_;
$self->_dbm_list([@dbm_list]);
return $self;
}
sub tie_dbm {
my $self = shift;
my $filename = $self->name;
my $dbm_class = $self->_dbm_class;
my $serializer = $self->_serializer;
eval "use MLDBM qw($dbm_class $serializer)";
$self->throw("Can't open '$filename' as MLDBM:\n$@") if $@;
my $hash;
my $db = tie %$hash, 'MLDBM', $filename, $self->mode, $self->perms,
@{$self->_dbm_extra}
or $self->throw("Can't open '$filename' as MLDBM file:\n$!");
$self->add_utf8_dbm_filter($db)
if $self->_has_utf8;
$self->tied_file($hash);
}
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::MLDBM - MLDBM Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

56
database/perl/vendor/lib/IO/All/Pipe.pm vendored Normal file
View File

@@ -0,0 +1,56 @@
use strict; use warnings;
package IO::All::Pipe;
use IO::All -base;
use IO::File;
const type => 'pipe';
sub pipe {
my $self = shift;
bless $self, __PACKAGE__;
$self->name(shift) if @_;
return $self->_init;
}
sub _assert_open {
my $self = shift;
return if $self->is_open;
$self->mode(shift) unless $self->mode;
$self->open;
}
sub open {
my $self = shift;
$self->is_open(1);
require IO::Handle;
$self->io_handle(IO::Handle->new)
unless defined $self->io_handle;
my $command = $self->name;
$command =~ s/(^\||\|$)//;
my $mode = shift || $self->mode || '<';
my $pipe_mode =
$mode eq '>' ? '|-' :
$mode eq '<' ? '-|' :
$self->throw("Invalid usage mode '$mode' for pipe");
CORE::open($self->io_handle, $pipe_mode, $command);
$self->_set_binmode;
}
my %mode_msg = (
'>' => 'output',
'<' => 'input',
'>>' => 'append',
);
sub open_msg {
my $self = shift;
my $name = defined $self->name
? " '" . $self->name . "'"
: '';
my $direction = defined $mode_msg{$self->mode}
? ' for ' . $mode_msg{$self->mode}
: '';
return qq{Can't open pipe$name$direction:\n$!};
}
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::Pipe - Pipe Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

View File

@@ -0,0 +1,54 @@
use strict; use warnings;
package IO::All::STDIO;
use IO::All -base;
use IO::File;
const type => 'stdio';
sub stdio {
my $self = shift;
bless $self, __PACKAGE__;
return $self->_init;
}
sub stdin {
my $self = shift;
$self->open('<');
return $self;
}
sub stdout {
my $self = shift;
$self->open('>');
return $self;
}
sub stderr {
my $self = shift;
$self->open_stderr;
return $self;
}
sub open {
my $self = shift;
$self->is_open(1);
my $mode = shift || $self->mode || '<';
my $fileno = $mode eq '>'
? fileno(STDOUT)
: fileno(STDIN);
$self->io_handle(IO::File->new);
$self->io_handle->fdopen($fileno, $mode);
$self->_set_binmode;
}
sub open_stderr {
my $self = shift;
$self->is_open(1);
$self->io_handle(IO::File->new);
$self->io_handle->fdopen(fileno(STDERR), '>') ? $self : 0;
}
# XXX Add overload support
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::STDIO - STDIO Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

View File

@@ -0,0 +1,142 @@
use strict; use warnings;
package IO::All::Socket;
use IO::All -base;
use IO::Socket;
const type => 'socket';
field _listen => undef;
option 'fork';
const domain_default => 'localhost';
chain domain => undef;
chain port => undef;
proxy_open 'recv';
proxy_open 'send';
sub socket {
my $self = shift;
bless $self, __PACKAGE__;
$self->name(shift) if @_;
return $self->_init;
}
sub socket_handle {
my $self = shift;
bless $self, __PACKAGE__;
$self->_handle(shift) if @_;
return $self->_init;
}
sub accept {
my $self = shift;
use POSIX ":sys_wait_h";
sub REAPER {
while (waitpid(-1, WNOHANG) > 0) {}
$SIG{CHLD} = \&REAPER;
}
local $SIG{CHLD};
$self->_listen(1);
$self->_assert_open;
my $server = $self->io_handle;
my $socket;
while (1) {
$socket = $server->accept;
last unless $self->_fork;
next unless defined $socket;
$SIG{CHLD} = \&REAPER;
my $pid = CORE::fork;
$self->throw("Unable to fork for IO::All::accept")
unless defined $pid;
last unless $pid;
close $socket;
undef $socket;
}
close $server if $self->_fork;
my $io = ref($self)->new->socket_handle($socket);
$io->io_handle($socket);
$io->is_open(1);
return $io;
}
sub shutdown {
my $self = shift;
my $how = @_ ? shift : 2;
my $handle = $self->io_handle;
$handle->shutdown(2)
if defined $handle;
}
sub _assert_open {
my $self = shift;
return if $self->is_open;
$self->mode(shift) unless $self->mode;
$self->open;
}
sub open {
my $self = shift;
return if $self->is_open;
$self->is_open(1);
$self->get_socket_domain_port;
my @args = $self->_listen
? (
LocalAddr => $self->domain,
LocalPort => $self->port,
Proto => 'tcp',
Listen => 1,
Reuse => 1,
)
: (
PeerAddr => $self->domain,
PeerPort => $self->port,
Proto => 'tcp',
);
my $socket = IO::Socket::INET->new(@args)
or $self->throw("Can't open socket");
$self->io_handle($socket);
$self->_set_binmode;
}
sub get_socket_domain_port {
my $self = shift;
my ($domain, $port);
($domain, $port) = split /:/, $self->name
if defined $self->name;
$self->domain($domain) unless defined $self->domain;
$self->domain($self->domain_default) unless $self->domain;
$self->port($port) unless defined $self->port;
return $self;
}
sub _overload_table {
my $self = shift;
(
$self->SUPER::_overload_table(@_),
'&{} socket' => '_overload_socket_as_code',
)
}
sub _overload_socket_as_code {
my $self = shift;
sub {
my $coderef = shift;
while ($self->is_open) {
$_ = $self->getline;
&$coderef($self);
}
}
}
sub _overload_any_from_any {
my $self = shift;
$self->SUPER::_overload_any_from_any(@_);
$self->close;
}
sub _overload_any_to_any {
my $self = shift;
$self->SUPER::_overload_any_to_any(@_);
$self->close;
}
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::Socket - Socket Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

View File

@@ -0,0 +1,34 @@
use strict; use warnings;
package IO::All::String;
use IO::All -base;
const type => 'string';
sub string_ref {
my ($self, $ref) = @_;
no strict 'refs';
*$self->{ref} = $ref if exists $_[1];
return *$self->{ref}
}
sub string {
my $self = shift;
bless $self, __PACKAGE__;
$self->_init;
}
sub open {
my $self = shift;
my $str = '';
my $ref = \$str;
$self->string_ref($ref);
open my $fh, '+<', $ref;
$self->io_handle($fh);
$self->_set_binmode;
$self->is_open(1);
}
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::String - String Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut

18
database/perl/vendor/lib/IO/All/Temp.pm vendored Normal file
View File

@@ -0,0 +1,18 @@
use strict; use warnings;
package IO::All::Temp;
use IO::All::File -base;
sub temp {
my $self = shift;
bless $self, __PACKAGE__;
my $temp_file = IO::File::new_tmpfile()
or $self->throw("Can't create temporary file");
$self->io_handle($temp_file);
$self->_error_check;
$self->autoclose(0);
$self->is_open(1);
return $self;
}
1;

View File

@@ -0,0 +1,21 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.46.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 NAME
IO::All::Temp - Temporary File Support for IO::All
=head1 SYNOPSIS
See L<IO::All>.
=head1 DESCRIPTION
<<<cpan-foot>>>
=cut