Filesys::Virtual::Base - A base class for virtual filesystems
package My::Virtual::FS; use base 'Filesys::Virtual::Base'; my $fs = Filesys::Virtual::Plain->new(); print foreach ($fs->list('/'));
This module is used by other modules to provide a virtual filesystem.
You can pass the initial cwd, root_path, and home_path as a hash.
Perform a perl type test on a file and returns the results.
For example to perform a -d on a directory.
$self->test('d','/testdir');
See filetests in perlfunc (commandline: perldoc perlfunc)
# -r File is readable by effective uid/gid. # -w File is writable by effective uid/gid. # -x File is executable by effective uid/gid. # -o File is owned by effective uid.
# -R File is readable by real uid/gid. # -W File is writable by real uid/gid. # -X File is executable by real uid/gid. # -O File is owned by real uid.
# -e File exists. # -z File has zero size. # -s File has nonzero size (returns size).
# -f File is a plain file. # -d File is a directory. # -l File is a symbolic link. # -p File is a named pipe (FIFO), or Filehandle is a pipe. # -S File is a socket. # -b File is a block special file. # -c File is a character special file. # -t Filehandle is opened to a tty.
# -u File has setuid bit set. # -g File has setgid bit set. # -k File has sticky bit set.
# -T File is a text file. # -B File is a binary file (opposite of -T).
# -M Age of file in days when script started. # -A Same for access time. # -C Same for inode change time.
Should create a directory with $mode (defaults to 0755) and chown()'s the directory with the uid and gid. The return value is from mkdir().
Should delete a file
Should delete the file or directory at $path if possible
List the files under $path
Returns a file handle which contains the data associated with $path
Closes a file handle that was opened with open_read.
Modifies the permissions of the filesystem. Returns blank by default.
Gets or sets the current directory, assumes / if blank. This is used in conjunction with the root_path for file operations. No actual change directory takes place.
Get or set the root path. All file paths are off this and cwd For example:
$self->root_path('/home/ftp'); $self->cwd('/test'); $self->size('testfile.txt');
The size command would get the size for file /home/ftp/test/testfile.txt not /test/testfile.txt
Gets the modification time of a file in YYYYMMDDHHMMSS format.
Gets the size of a file in bytes.
Deletes a file, returns 1 or 0 on success or failure.
Changes the cwd to a new path from root_path. Returns undef on failure or the new path on success.
Returns an array of the files in ls format.
Performs a $fh->close()
Performs a $fh->seek($pos, $wence). See IO::Seekable.
Performs a utime() on the file(s). It changes the access time and mod time of those files.
Lots. This really shouldn't be used yet until coverage is strengthened. Next up, we should provide higher level abstractions for certain kinds of file operations, such as copy and move. Additionally, there seems to be a bit of boiler plate required at the beginning of each method implementation, so abstracting the calls a bit more should be done in the near future.
copy
move
Norman Nunley <nnunley@cpan.org>, based on the work of David Davis, <xantus@cpan.org>, http://teknikill.net/
perl(1), Filesys::Virtual, Filesys::Virtual::Plain, POE::Component::Server::FTP, Net::DAV::Server, HTTP::Daemon, http://perladvent.org/2004/20th/
To install Filesys::Virtual::Base, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Filesys::Virtual::Base
CPAN shell
perl -MCPAN -e shell install Filesys::Virtual::Base
For more information on module installation, please visit the detailed CPAN module installation guide.