Bio-KBase
view release on metacpan or search on metacpan
lib/Bio/KBase/InvocationService/InvocationServiceImpl.pm view on Meta::CPAN
name has a value which is a string
full_path has a value which is a string
mod_date has a value which is a string
file is a reference to a hash where the following keys are defined:
name has a value which is a string
full_path has a value which is a string
mod_date has a value which is a string
size has a value which is a string
=end text
=item Description
=back
=cut
sub list_files
{
my $self = shift;
my($session_id, $cwd, $d) = @_;
my @_bad_arguments;
(!ref($session_id)) or push(@_bad_arguments, "Invalid type for argument \"session_id\" (value was \"$session_id\")");
(!ref($cwd)) or push(@_bad_arguments, "Invalid type for argument \"cwd\" (value was \"$cwd\")");
(!ref($d)) or push(@_bad_arguments, "Invalid type for argument \"d\" (value was \"$d\")");
if (@_bad_arguments) {
my $msg = "Invalid arguments passed to list_files:\n" . join("", map { "\t$_\n" } @_bad_arguments);
Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg,
method_name => 'list_files');
}
my $ctx = $Bio::KBase::InvocationService::Service::CallContext;
my($return_1, $return_2);
#BEGIN list_files
my $dir = $self->_expand_filename($session_id, $d, $cwd);
my $fpath;
my $base = $self->_session_dir($session_id);
if ($dir =~ /^$base(.*)/)
{
$fpath = $1 ? $1 : "/";
}
else
{
die "Invalid path $dir";
}
my @dirs;
my @files;
my $dh;
opendir($dh, $dir) or die "Cannot open directory: $!";
while (my $file = readdir($dh)) {
next if ($file =~ m/^\./);
my($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat("$dir/$file");
my $date= strftime("%b %d %G %H:%M:%S", localtime($mtime));
if (-f "$dir/$file") {
push @files, { name => $file, full_path => "$fpath/$file", mod_date => $date, size => $size};
} elsif (-d "$dir/$file") {
push @dirs, { name => $file, full_path => "$fpath/$file", mod_date => $date };
}
}
$return_1 = \@dirs;
$return_2 = \@files;
closedir($dh);
#END list_files
my @_bad_returns;
(ref($return_1) eq 'ARRAY') or push(@_bad_returns, "Invalid type for return variable \"return_1\" (value was \"$return_1\")");
(ref($return_2) eq 'ARRAY') or push(@_bad_returns, "Invalid type for return variable \"return_2\" (value was \"$return_2\")");
if (@_bad_returns) {
my $msg = "Invalid returns passed to list_files:\n" . join("", map { "\t$_\n" } @_bad_returns);
Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg,
method_name => 'list_files');
}
return($return_1, $return_2);
}
=head2 remove_files
$obj->remove_files($session_id, $cwd, $filename)
=over 4
=item Parameter and return types
=begin html
<pre>
$session_id is a string
$cwd is a string
$filename is a string
</pre>
=end html
=begin text
$session_id is a string
$cwd is a string
$filename is a string
=end text
( run in 2.582 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )