POE-Devel-ProcAlike
view release on metacpan or search on metacpan
lib/POE/Devel/ProcAlike/POEInfo.pm view on Meta::CPAN
} elsif ( $type eq 'open' ) {
# get the data to start off
my @sessions = $api->session_list();
my @data = grep { $_->ID eq $path[0] } @sessions;
if ( ! @data or ! defined $path[1] ) {
return;
}
# is it a valid session metric?
if ( ! grep { $_ eq $path[1] } @{ _get_sessions_metrics() } or defined $path[2] ) {
return;
}
# get the metric!
my $data = _get_sessions_metric( $data[0], $path[1] );
return \$data;
}
}
# we cheat here and not implement a lot of stuff because we know the FUSE api never calls the "extra" APIs
# that ::Async provides. Furthermore, this is a read-only filesystem so we can skip even more APIs :)
# _rmtree
# _scandir
# _move
# _copy
# _load
sub _readdir {
my( $self, $path ) = @_;
if ( $path eq File::Spec->rootdir() ) {
return [ keys %fs ];
} else {
# sanitize the path
my @dirs = File::Spec->splitdir( $path );
shift( @dirs ); # get rid of the root entry which is always '' for me
return $fs{ $dirs[0] }->( 'readdir', @dirs[ 1 .. $#dirs ] );
}
}
# _rmdir
# _mkdir
# _rename
# _mknod
# _unlink
# _chmod
# _truncate
# _chown
# _utime
# helper to process ARRAY fs type
sub _stat_arraymode {
my $file = shift;
my $method = $fs{ $file }->[1];
my $data = $fs{ $file }->[0]->$method();
# do we need to do more munging?
if ( defined $fs{ $file }->[2] ) {
$data = $fs{ $file }->[2]->( $data );
}
# all done!
return $data . "\n";
}
sub _stat {
my( $self, $path ) = @_;
# stating the root?
if ( $path eq File::Spec->rootdir() ) {
my ($atime, $ctime, $mtime, $size, $modes);
$atime = $ctime = $mtime = time();
my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = ( 0, 0, 0, 1, (split( /\s+/, $) ))[0], $>, 1, 1024 );
$size = 0;
$modes = oct( '040755' );
# count subdirs
$nlink = 2 + grep { ref $fs{ $_ } and ref( $fs{ $_ } ) ne 'ARRAY' } keys %fs;
return( [ $dev, $ino, $modes, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ] );
}
# sanitize the path
my @dirs = File::Spec->splitdir( $path );
shift( @dirs ); # get rid of the root entry which is always '' for me
if ( exists $fs{ $dirs[0] } ) {
# arg, stat is a finicky beast!
my $modes = oct( '100644' );
my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = ( 0, 0, 0, 1, (split( /\s+/, $) ))[0], $>, 1, 1024 );
my ($atime, $ctime, $mtime, $size);
$atime = $ctime = $mtime = time();
# directory or file?
if ( ref $fs{ $dirs[0] } ) {
# array or code?
if ( ref( $fs{ $dirs[0] } ) eq 'ARRAY' ) {
# array operation, do what the data tells us to do!
$size = length( _stat_arraymode( $dirs[0] ) );
} else {
# trying to stat the dir or the subpath?
return $fs{ $dirs[0] }->( 'stat', @dirs[ 1 .. $#dirs ] );
}
} else {
# arg, stat is a finicky beast!
$size = length( $fs{ $dirs[0] } );
}
( run in 1.601 second using v1.01-cache-2.11-cpan-364913b4093 )