ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / doc / html / gnome-vfs-gnome-vfs-file-rw-ops.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Reading and Writing</title><meta name="generator" content="DocBook XSL Stylesheets V1.61.0"><meta name="generator" content="GTK-Doc V1.1 (XML mode)"><style type="text/css">
2         .synopsis, .classsynopsis {
3             background: #eeeeee;
4             border: solid 1px #aaaaaa;
5             padding: 0.5em;
6         }
7         .programlisting {
8             background: #eeeeff;
9             border: solid 1px #aaaaff;
10             padding: 0.5em;
11         }
12         .variablelist {
13             padding: 4px;
14             margin-left: 3em;
15         }
16         .navigation {
17             background: #ffeeee;
18             border: solid 1px #ffaaaa;
19             margin-top: 0.5em;
20             margin-bottom: 0.5em;
21         }
22         .navigation a {
23             color: #770000;
24         }
25         .navigation a:visited {
26             color: #550000;
27         }
28         .navigation .title {
29             font-size: 200%;
30         }
31       </style><link rel="home" href="index.html" title="GnomeVFS - Filesystem Abstraction library"><link rel="up" href="gnome-vfs-file-operations.html" title="File Handling"><link rel="previous" href="gnome-vfs-gnome-vfs-file-basic-ops.html" title="Basic File Operations"><link rel="next" href="gnome-vfs-gnome-vfs-file-info-ops.html" title="Getting and Setting File Information"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="gnome-vfs-gnome-vfs-file-basic-ops.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="gnome-vfs-file-operations.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GnomeVFS - Filesystem Abstraction library</th><td><a accesskey="n" href="gnome-vfs-gnome-vfs-file-info-ops.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="gnome-vfs-gnome-vfs-file-rw-ops"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Reading and Writing</span></h2><p>Reading and Writing &#8212; </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
32
33
34
35 enum        <a href="gnome-vfs-gnome-vfs-file-rw-ops.html#GnomeVFSSeekPosition">GnomeVFSSeekPosition</a>;
36 <a href="gnome-vfs-gnome-vfs-result.html#GnomeVFSResult">GnomeVFSResult</a> <a href="gnome-vfs-gnome-vfs-file-rw-ops.html#gnome-vfs-read">gnome_vfs_read</a>               (GnomeVFSHandle *handle,
37                                              <a
38 href="../glib/glib-Basic-Types.html#gpointer"
39 >gpointer</a> buffer,
40                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> bytes,
41                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> *bytes_read);
42 <a href="gnome-vfs-gnome-vfs-result.html#GnomeVFSResult">GnomeVFSResult</a> <a href="gnome-vfs-gnome-vfs-file-rw-ops.html#gnome-vfs-write">gnome_vfs_write</a>              (GnomeVFSHandle *handle,
43                                              <a
44 href="../glib/glib-Basic-Types.html#gconstpointer"
45 >gconstpointer</a> buffer,
46                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> bytes,
47                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> *bytes_written);
48 <a href="gnome-vfs-gnome-vfs-result.html#GnomeVFSResult">GnomeVFSResult</a> <a href="gnome-vfs-gnome-vfs-file-rw-ops.html#gnome-vfs-seek">gnome_vfs_seek</a>               (GnomeVFSHandle *handle,
49                                              <a href="gnome-vfs-gnome-vfs-file-rw-ops.html#GnomeVFSSeekPosition">GnomeVFSSeekPosition</a> whence,
50                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileOffset">GnomeVFSFileOffset</a> offset);
51 <a href="gnome-vfs-gnome-vfs-result.html#GnomeVFSResult">GnomeVFSResult</a> <a href="gnome-vfs-gnome-vfs-file-rw-ops.html#gnome-vfs-tell">gnome_vfs_tell</a>               (GnomeVFSHandle *handle,
52                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> *offset_return);
53 </pre></div><div class="refsect1" lang="en"><h2>Description</h2><p>
54   Reading and writing operations are explained, also <i class="parameter"><tt>gnome_vfs_seek</tt></i>, which
55   is used to move the file pointer inside the file.
56 </p></div><div class="refsect1" lang="en"><h2>Details</h2><div class="refsect2" lang="en"><h3><a name="GnomeVFSSeekPosition"></a>enum GnomeVFSSeekPosition</h3><pre class="programlisting">typedef enum {
57         GNOME_VFS_SEEK_START,
58         GNOME_VFS_SEEK_CURRENT,
59         GNOME_VFS_SEEK_END
60 } GnomeVFSSeekPosition;
61 </pre><p>
62 This is used to specify the start position for seek operations.</p><p>
63
64 </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><tt class="literal">GNOME_VFS_SEEK_START</tt></span></td><td> Start of the file.
65 </td></tr><tr><td><span class="term"><tt class="literal">GNOME_VFS_SEEK_CURRENT</tt></span></td><td> Current position.
66 </td></tr><tr><td><span class="term"><tt class="literal">GNOME_VFS_SEEK_END</tt></span></td><td> End of the file.
67 </td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><h3><a name="gnome-vfs-read"></a>gnome_vfs_read ()</h3><pre class="programlisting"><a href="gnome-vfs-gnome-vfs-result.html#GnomeVFSResult">GnomeVFSResult</a> gnome_vfs_read               (GnomeVFSHandle *handle,
68                                              <a
69 href="../glib/glib-Basic-Types.html#gpointer"
70 >gpointer</a> buffer,
71                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> bytes,
72                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> *bytes_read);</pre><p>
73 Read <i class="parameter"><tt>bytes</tt></i> from <i class="parameter"><tt>handle</tt></i>.  As with Unix system calls, the number of
74 bytes read can effectively be less than <i class="parameter"><tt>bytes</tt></i> on return and will be
75 stored in <i class="parameter"><tt>bytes_read</tt></i>.</p><p>
76
77 </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>handle</tt></i> :</span></td><td> Handle of the file to read data from
78 </td></tr><tr><td><span class="term"><i class="parameter"><tt>buffer</tt></i> :</span></td><td> Pointer to a buffer that must be at least <i class="parameter"><tt>bytes</tt></i> bytes large
79 </td></tr><tr><td><span class="term"><i class="parameter"><tt>bytes</tt></i> :</span></td><td> Number of bytes to read
80 </td></tr><tr><td><span class="term"><i class="parameter"><tt>bytes_read</tt></i> :</span></td><td> Pointer to a variable that will hold the number of bytes
81 effectively read on return.
82 </td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> An integer representing the result of the operation
83 </td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><h3><a name="gnome-vfs-write"></a>gnome_vfs_write ()</h3><pre class="programlisting"><a href="gnome-vfs-gnome-vfs-result.html#GnomeVFSResult">GnomeVFSResult</a> gnome_vfs_write              (GnomeVFSHandle *handle,
84                                              <a
85 href="../glib/glib-Basic-Types.html#gconstpointer"
86 >gconstpointer</a> buffer,
87                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> bytes,
88                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> *bytes_written);</pre><p>
89 Write <i class="parameter"><tt>bytes</tt></i> into the file opened through <i class="parameter"><tt>handle</tt></i>.  As with Unix system
90 calls, the number of bytes written can effectively be less than <i class="parameter"><tt>bytes</tt></i> on
91 return and will be stored in <i class="parameter"><tt>bytes_written</tt></i>.</p><p>
92
93 </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>handle</tt></i> :</span></td><td> Handle of the file to write data to
94 </td></tr><tr><td><span class="term"><i class="parameter"><tt>buffer</tt></i> :</span></td><td> Pointer to the buffer containing the data to be written
95 </td></tr><tr><td><span class="term"><i class="parameter"><tt>bytes</tt></i> :</span></td><td> Number of bytes to write
96 </td></tr><tr><td><span class="term"><i class="parameter"><tt>bytes_written</tt></i> :</span></td><td> Pointer to a variable that will hold the number of bytes
97 effectively written on return.
98 </td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> An integer representing the result of the operation
99 </td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><h3><a name="gnome-vfs-seek"></a>gnome_vfs_seek ()</h3><pre class="programlisting"><a href="gnome-vfs-gnome-vfs-result.html#GnomeVFSResult">GnomeVFSResult</a> gnome_vfs_seek               (GnomeVFSHandle *handle,
100                                              <a href="gnome-vfs-gnome-vfs-file-rw-ops.html#GnomeVFSSeekPosition">GnomeVFSSeekPosition</a> whence,
101                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileOffset">GnomeVFSFileOffset</a> offset);</pre><p>
102 Set the current position for reading/writing through <i class="parameter"><tt>handle</tt></i>.</p><p>
103
104 </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>handle</tt></i> :</span></td><td> Handle for which the current position must be changed
105 </td></tr><tr><td><span class="term"><i class="parameter"><tt>whence</tt></i> :</span></td><td> Integer value representing the starting position
106 </td></tr><tr><td><span class="term"><i class="parameter"><tt>offset</tt></i> :</span></td><td> Number of bytes to skip from the position specified by <i class="parameter"><tt>whence</tt></i>
107 (a positive value means to move forward; a negative one to move backwards)
108 </td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> 
109 </td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><h3><a name="gnome-vfs-tell"></a>gnome_vfs_tell ()</h3><pre class="programlisting"><a href="gnome-vfs-gnome-vfs-result.html#GnomeVFSResult">GnomeVFSResult</a> gnome_vfs_tell               (GnomeVFSHandle *handle,
110                                              <a href="gnome-vfs-gnome-vfs-file-size.html#GnomeVFSFileSize">GnomeVFSFileSize</a> *offset_return);</pre><p>
111 Return the current position on <i class="parameter"><tt>handle</tt></i>. This is the point in the file
112 pointed to by handle that reads and writes will occur on.</p><p>
113
114 </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>handle</tt></i> :</span></td><td> Handle for which the current position must be retrieved
115 </td></tr><tr><td><span class="term"><i class="parameter"><tt>offset_return</tt></i> :</span></td><td> Pointer to a variable that will contain the current position
116 on return
117 </td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> An integer representing the result of the operation
118 </td></tr></tbody></table></div></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="gnome-vfs-gnome-vfs-file-basic-ops.html"><b>&lt;&lt; Basic File Operations</b></a></td><td align="right"><a accesskey="n" href="gnome-vfs-gnome-vfs-file-info-ops.html"><b>Getting and Setting File Information &gt;&gt;</b></a></td></tr></table></body></html>