Net::FSP::Entry - An FSP directory entry


Net-FSP documentation Contained in the Net-FSP distribution.

Index


Code Index:

NAME

Top

Net::FSP::Entry - An FSP directory entry

VERSION

Top

This documentation refers to Net::FSP version 0.13

DESCRIPTION

Top

In FSP there are two kinds of entries, files and directories. This is the base class of the corresponding types: Net::FSP::File and Net::FSP::Dir.

METHODS

Top

name()

Returns the full name of the entry.

short_name

Returns the basename of the entry.

type()

Returns file or dir, depending on the type of entry.

move($new_location)

Move this entry to a new location.

remove()

Remove this entry.

download($sink = $self->name)

Download this entry.

size()

Returns the size (in bytes) of the entry.

time()

Returns the modification time of the entry (in seconds since UNIX epoch).

Returns the location the symlink is pointing to, or undef if the entry is not a symlink.

accept($visitor)

Accept a visitor. This visitor must be a subref.

AUTHOR

Top

Leon Timmermans, fawaka@gmail.com

LICENSE AND COPYRIGHT

Top


Net-FSP documentation Contained in the Net-FSP distribution.

package Net::FSP::Entry;
use strict;
use warnings;
use Carp;

use overload q{""} => sub {
	return $_[0]->short_name;
};
our $VERSION = $Net::FSP::VERSION;

sub new {
	my ($class, $fsp, $name, %attributes) = @_;
	$name =~ s{ \A / }{}mx;
	return bless {
		fsp  => $fsp,
		name => $name,
		%attributes,
	}, $class;
}

for my $subname (qw/name type size time link/) {
	no strict 'refs';    ##no critic strict
	*{$subname} = sub {
		return $_[0]{$subname};
	};
}

sub move {
	my ($self, $new_name) = @_;
	$self->{fsp}->move_file($self->{name}, $new_name);
	return;
}

sub short_name {
	my $self = shift;
	$self->{name} =~ / ( [^\/]* ) \z /mx or croak "Couldn't determine short_name";
	return $1;
}

sub accept;
sub remove;
sub download;

1;

__END__