- SEE ALSO
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.
'>' output to a file
'<' input from a file
'>>' append to a file ( this is broken in RH8.0 as gnome_vfs_seek is broken )
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.
- 0 dev device number of filesystem (currently undef)
- 1 inode inode number (currently undef)
- 2 mode file mode (type and permissions in character form)
- 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
- 14 name a new entry specifying the file name ( minus the path )
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:
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.
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 - email@example.com
http://developer.gnome.org/doc/API/gnome-vfs/ and perldoc Tie::Handle
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'