<refentry id="gnome-vfs-20-gnome-vfs-file-rw-ops">
<refmeta>
<refentrytitle id="top_of_page">Reading and Writing</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GNOME-VFS-2.0 Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Reading and Writing</refname>
<refpurpose></refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv id="synopsis">
<title id="synopsis.title">Synopsis</title>

<synopsis>



enum        <link linkend="GnomeVFSSeekPosition">GnomeVFSSeekPosition</link>;
<link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-read">gnome_vfs_read</link>               (<link linkend="GnomeVFSHandle">GnomeVFSHandle</link> *handle,
                                             <link linkend="gpointer">gpointer</link> buffer,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> bytes,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> *bytes_read);
<link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-write">gnome_vfs_write</link>              (<link linkend="GnomeVFSHandle">GnomeVFSHandle</link> *handle,
                                             <link linkend="gconstpointer">gconstpointer</link> buffer,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> bytes,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> *bytes_written);
<link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-seek">gnome_vfs_seek</link>               (<link linkend="GnomeVFSHandle">GnomeVFSHandle</link> *handle,
                                             <link linkend="GnomeVFSSeekPosition">GnomeVFSSeekPosition</link> whence,
                                             <link linkend="GnomeVFSFileOffset">GnomeVFSFileOffset</link> offset);
<link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-tell">gnome_vfs_tell</link>               (<link linkend="GnomeVFSHandle">GnomeVFSHandle</link> *handle,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> *offset_return);
</synopsis>
</refsynopsisdiv>









<refsect1 id="desc">
<title id="desc.title">Description</title>
<para>
  Reading and writing operations are explained, also <parameter>gnome_vfs_seek</parameter>, which
  is used to move the file pointer inside the file.
</para>
</refsect1>

<refsect1 id="details">
<title id="details.title">Details</title>
<refsect2>
<title><anchor id="GnomeVFSSeekPosition" role="enum"/>enum GnomeVFSSeekPosition</title>
<indexterm><primary>GnomeVFSSeekPosition</primary></indexterm><programlisting>typedef enum {
        GNOME_VFS_SEEK_START,
        GNOME_VFS_SEEK_CURRENT,
        GNOME_VFS_SEEK_END
} GnomeVFSSeekPosition;
</programlisting>
<para>
This is used to specify the start position for seek operations.</para>
<para>

</para><variablelist role="enum">
<varlistentry>
<term><literal>GNOME_VFS_SEEK_START</literal></term>
<listitem><simpara> Start of the file.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><literal>GNOME_VFS_SEEK_CURRENT</literal></term>
<listitem><simpara> Current position.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><literal>GNOME_VFS_SEEK_END</literal></term>
<listitem><simpara> End of the file.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-read" role="function"/>gnome_vfs_read ()</title>
<indexterm><primary>gnome_vfs_read</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_read               (<link linkend="GnomeVFSHandle">GnomeVFSHandle</link> *handle,
                                             <link linkend="gpointer">gpointer</link> buffer,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> bytes,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> *bytes_read);</programlisting>
<para>
Read <parameter>bytes</parameter> from <parameter>handle</parameter>.  As with Unix system calls, the number of
bytes read can effectively be less than <parameter>bytes</parameter> on return and will be
stored in <parameter>bytes_read</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>handle</parameter>&nbsp;:</term>
<listitem><simpara> handle of the file to read data from.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>buffer</parameter>&nbsp;:</term>
<listitem><simpara> pointer to a buffer that must be at least <parameter>bytes</parameter> bytes large.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>bytes</parameter>&nbsp;:</term>
<listitem><simpara> number of bytes to read.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>bytes_read</parameter>&nbsp;:</term>
<listitem><simpara> pointer to a variable that will hold the number of bytes
effectively read on return.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> an integer representing the result of the operation.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-write" role="function"/>gnome_vfs_write ()</title>
<indexterm><primary>gnome_vfs_write</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_write              (<link linkend="GnomeVFSHandle">GnomeVFSHandle</link> *handle,
                                             <link linkend="gconstpointer">gconstpointer</link> buffer,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> bytes,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> *bytes_written);</programlisting>
<para>
Write <parameter>bytes</parameter> into the file opened through <parameter>handle</parameter>.  As with Unix system
calls, the number of bytes written can effectively be less than <parameter>bytes</parameter> on
return and will be stored in <parameter>bytes_written</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>handle</parameter>&nbsp;:</term>
<listitem><simpara> handle of the file to write data to.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>buffer</parameter>&nbsp;:</term>
<listitem><simpara> pointer to the buffer containing the data to be written.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>bytes</parameter>&nbsp;:</term>
<listitem><simpara> number of bytes to write.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>bytes_written</parameter>&nbsp;:</term>
<listitem><simpara> pointer to a variable that will hold the number of bytes
effectively written on return.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> an integer representing the result of the operation.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-seek" role="function"/>gnome_vfs_seek ()</title>
<indexterm><primary>gnome_vfs_seek</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_seek               (<link linkend="GnomeVFSHandle">GnomeVFSHandle</link> *handle,
                                             <link linkend="GnomeVFSSeekPosition">GnomeVFSSeekPosition</link> whence,
                                             <link linkend="GnomeVFSFileOffset">GnomeVFSFileOffset</link> offset);</programlisting>
<para>
Set the current position for reading/writing through <parameter>handle</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>handle</parameter>&nbsp;:</term>
<listitem><simpara> handle for which the current position must be changed.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>whence</parameter>&nbsp;:</term>
<listitem><simpara> integer value representing the starting position.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset</parameter>&nbsp;:</term>
<listitem><simpara> number of bytes to skip from the position specified by <parameter>whence</parameter>.
(a positive value means to move forward; a negative one to move backwards).
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> an integer representing the result of the operation.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-tell" role="function"/>gnome_vfs_tell ()</title>
<indexterm><primary>gnome_vfs_tell</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_tell               (<link linkend="GnomeVFSHandle">GnomeVFSHandle</link> *handle,
                                             <link linkend="GnomeVFSFileSize">GnomeVFSFileSize</link> *offset_return);</programlisting>
<para>
Return the current position on <parameter>handle</parameter>. This is the point in the file
pointed to by handle that reads and writes will occur on.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>handle</parameter>&nbsp;:</term>
<listitem><simpara> handle for which the current position must be retrieved.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset_return</parameter>&nbsp;:</term>
<listitem><simpara> pointer to a variable that will contain the current position
on return.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> an integer representing the result of the operation.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
