1VFS(3) User Contributed Perl Documentation VFS(3)
2
3
4
6 Gnome2::VFS - Perl interface to the 2.x series of the GNOME VFS library
7
9 use Gnome2::VFS;
10
11 sub die_already {
12 my ($action) = @_;
13 die("An error occured while $action.\n");
14 }
15
16 die_already("initializing GNOME VFS") unless (Gnome2::VFS -> init());
17
18 my $source = "http://www.perldoc.com/about.html";
19 my ($result, $handle, $info);
20
21 # Open a connection to Perldoc.
22 ($result, $handle) = Gnome2::VFS -> open($source, "read");
23 die_already("opening connection to '$source'")
24 unless ($result eq "ok");
25
26 # Get the file information.
27 ($result, $info) = $handle -> get_file_info("default");
28 die_already("retrieving information about '$source'")
29 unless ($result eq "ok");
30
31 # Read the content.
32 my $bytes = $info -> { size };
33
34 my $bytes_read = 0;
35 my $buffer = "";
36
37 do {
38 my ($tmp_buffer, $tmp_bytes_read);
39
40 ($result, $tmp_bytes_read, $tmp_buffer) =
41 $handle -> read($bytes - $bytes_read);
42
43 $buffer .= $tmp_buffer;
44 $bytes_read += $tmp_bytes_read;
45 } while ($result eq "ok" and $bytes_read < $bytes);
46
47 die_already("reading $bytes bytes from '$source'")
48 unless ($result eq "ok" && $bytes_read == $bytes);
49
50 # Close the connection.
51 $result = $handle -> close();
52 die_already("closing connection to '$source'")
53 unless ($result eq "ok");
54
55 # Create and open the target.
56 my $target = "/tmp/" . $info -> { name };
57 my $uri = Gnome2::VFS::URI -> new($target);
58
59 ($result, $handle) = $uri -> create("write", 1, 0644);
60 die_already("creating '$target'") unless ($result eq "ok");
61
62 # Write to it.
63 my $bytes_written;
64
65 ($result, $bytes_written) = $handle -> write($buffer, $bytes);
66 die_already("writing $bytes bytes to '$target'")
67 unless ($result eq "ok" && $bytes_written == $bytes);
68
69 # Close the target.
70 $result = $handle -> close();
71 die_already("closing '$target'") unless ($result eq "ok");
72
73 Gnome2::VFS -> shutdown();
74
76 This module allows you to interface with the GNOME Virtual File System
77 library. It provides the means to transparently access files on all
78 kinds of filesystems.
79
81 Since this module tries to stick very closely to the C API, the docu‐
82 mentation found at
83
84 L<http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/>
85
86 is the canonical reference.
87
88 In addition to that, there's also the automatically generated API docu‐
89 mentation: Gnome2::VFS::index.
90
91 The mapping described in Gtk2::api also applies to this module.
92
93 To discuss this module, ask questions and flame/praise the authors,
94 join gtk-perl-list@gnome.org at lists.gnome.org.
95
97 There are some memory leaks especially with respect to callbacks. This
98 mainly affects GnomeVFSAsync as well as some parts of GnomeVFSXfer and
99 GnomeVFSOps. GnomeVFSMime leaks some list data.
100
101 GnomeVFSAsync is also known to crash under certain conditions when
102 there are many concurrent transfers.
103
105 Gnome2::VFS::index, Glib, Gtk2, Gtk2::api.
106
108 Torsten Schoenfeld <kaffeetisch@web.de>.
109
111 Copyright (C) 2003-2007 by the gtk2-perl team (see the file AUTHORS)
112
113 This library is free software; you can redistribute it and/or modify it
114 under the terms of the GNU Lesser General Public License as published
115 by the Free Software Foundation; either version 2.1 of the License, or
116 (at your option) any later version.
117
118 This library is distributed in the hope that it will be useful, but
119 WITHOUT ANY WARRANTY; without even the implied warranty of MER‐
120 CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
121 General Public License for more details.
122
123 You should have received a copy of the GNU Lesser General Public
124 License along with this library; if not, write to the Free Software
125 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
126 USA
127
128
129
130perl v5.8.8 2007-10-24 VFS(3)