NAME
VFS::GnomeVFS - Gnome Virtual Filesystem for Perl
SYNOPSIS
use VFS::GnomeVFS;
vfsopen(*IN, "<http://www.piersharding.com") or die $!;
# dont forget the * when using strict
print while (<IN>);
close IN;
DESCRIPTION
VFS::GnomeVFS is a TIEHANDLE module that uses the gnome-vfs library from the Gnome project (http://www.gnome.org). The gnome-vfs library (Virtual File System) allows uniform access to various uri types such as http://, https://, file://, ftp:// etc.
METHODS
vfsopen()
vfsopen is pushed into the users calling namespace via the import statement, so there is no need to fully qualify it.
vfsopen(*FH, ">file:///tmp/some.file") or die $!;
Because use strict forbids the use of barewords, then you must remember to use the * (typeglob notation) on your filehandle - but only for the vfsopen there after it is not required.
VFS::GnomeVFS supports:
'>' output to a file
'<' input from a file
'>>' append to a file ( this is broken in RH8.0 as gnome_vfs_seek is broken )
other functions
once opened - a file handle behaves much like an ordinary one, in that you can "print" to it, and read from it with the "<>" (diamond) operator.
vfsstat()
vfsstat takes a single argument of a uri and returns a 13 element array of information as the core perl stat() function does.
- 0 dev device number of filesystem (currently undef)
- 1 inode inode number (currently undef)
- 2 mode file mode (type and permissions in character form)
- 3 nlink number of (hard) links to the file
- 4 uid numeric user ID of file's owner
- 5 gid numeric group ID of file's owner
- 6 rdev the device identifier (special files only)
- 7 size total size of file, in bytes
- 8 atime last access time in seconds since the epoch
- 9 mtime last modify time in seconds since the epoch
- 10 ctime inode change time (NOT creation time!) in seconds since the epoch
- 11 blksize preferred block size for file system I/O
- 12 blocks actual number of blocks allocated
- 13 type a new entry specifying the type This can be f - file, d - directory, p - pipe, s - socket, c - character device, b - block device, l - link
- 14 name a new entry specifying the file name ( minus the path )
vfsexists()
vfsexists takes a single argument of a uri and returns true if it exists.
vfsmove()
vfsmove takes two arguments - the from and to uri's, and returns true if the file was successfully transported.
vfsunlink()
vfsunlink takes a single argument of a uri and returns true if the file is successfully unlinked/deleted.
vfsopendir()
vfsopendir opens a handle on a directory in the same style as a TIED files handle. This is used in preference to trying to imitate the opendir, readdir, closedir syntax of Perl, that can not be imitated thru the tie() operation.
vfsopendir(*DIR, "file:///tmp") or die $!;
Because use strict forbids the use of barewords, then you must remember to use the * (typeglob notation) on your filehandle - but only for the vfsopendir there after it is not required.
subsequently the handle can be addressed in two ways:
in array context
in scalar context
Array context emulates individual readdir commands of standard Perl, in that it returns a list of names read from the given directory.
push(@a, (<DIR>));
Scalar context returns the results of individual stat commands as an array ref. This is what gnome-vfs does natively. The first element of the stat array has been highjacked to supply the files name.
while($dirent = <DIR>) push(@a, $dirent->[0]);
VERSION
very new
AUTHOR
Piers Harding - piers@cpan.org
SEE ALSO
http://developer.gnome.org/doc/API/gnome-vfs/ and perldoc Tie::Handle
COPYRIGHT
Copyright (c) 2002, Piers Harding. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 417:
You forgot a '=back' before '=head1'