VFS::Gnome - Gnome Virtual Filesystem for Perl
use VFS::Gnome; vfsopen(*IN, "<http://www.piersharding.com") or die $!; # dont forget the * when using strict print while (<IN>); close IN;
VFS::Gnome 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.
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.
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 takes a single argument of a uri and returns a 13 element array of information as the core perl stat() function does.
vfsexists takes a single argument of a uri and returns true if it exists.
vfsmove takes two arguments - the from and to uri's, and returns true if the file was successfully transported.
vfsunlink takes a single argument of a uri and returns true if the file is successfully unlinked/deleted.
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:
Array context emulates individual readdir commands of standard Perl, in that it returns a list of names read from the given directory.
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->);
Piers Harding - firstname.lastname@example.org
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.