Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > dc9b9eb224888fd532330fad8ee0ffc5 > files > 579

audacious-devel-2.4.5-1.fc14.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Audacious: vfs_buffered_file.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Audacious&#160;<span id="projectnumber">$Id:Doxyfile42802007-03-2104:39:00Znenolod$</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>vfs_buffered_file.c</h1>  </div>
</div>
<div class="contents">
<a href="vfs__buffered__file_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *  Copyright (c) 2006-2007 William Pitcock</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> *  This program is free software; you can redistribute it and/or modify</span>
<a name="l00005"></a>00005 <span class="comment"> *  it under the terms of the GNU General Public License as published by</span>
<a name="l00006"></a>00006 <span class="comment"> *  the Free Software Foundation; under version 3 of the License.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> *  This program is distributed in the hope that it will be useful,</span>
<a name="l00009"></a>00009 <span class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00010"></a>00010 <span class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00011"></a>00011 <span class="comment"> *  GNU General Public License for more details.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> *  You should have received a copy of the GNU General Public License</span>
<a name="l00014"></a>00014 <span class="comment"> *  along with this program.  If not, see &lt;http://www.gnu.org/licenses&gt;.</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> *  The Audacious team does not consider modular code linking to</span>
<a name="l00017"></a>00017 <span class="comment"> *  Audacious or using our public API to be a derived work.</span>
<a name="l00018"></a>00018 <span class="comment"> */</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;glib.h&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="vfs_8h.html" title="Main API header for accessing Audacious VFS functionality.">vfs.h</a>&quot;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="vfs__buffer_8h.html">vfs_buffer.h</a>&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="vfs__buffered__file_8h.html" title="Functions and structures for buffered file access over VFS.">vfs_buffered_file.h</a>&quot;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <a class="code" href="structVFSFile.html">VFSFile</a> *
<a name="l00027"></a><a class="code" href="vfs__buffered__file_8c.html#aa2f38f9d8e6ae969cad936708278681f">00027</a> <a class="code" href="vfs__buffered__file_8c.html#aa2f38f9d8e6ae969cad936708278681f">buffered_file_vfs_fopen_impl</a>(<span class="keyword">const</span> gchar * <a class="code" href="plugins-api_8h.html#aed23534511ec9dec0630ca4854c4552b">path</a>,
<a name="l00028"></a>00028           <span class="keyword">const</span> gchar * mode)
<a name="l00029"></a>00029 {
<a name="l00030"></a>00030     <span class="keywordflow">return</span> NULL;
<a name="l00031"></a>00031 }
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a>
<a name="l00034"></a><a class="code" href="vfs__buffered__file_8c.html#a93b33fbbe4ac43469a7a2a784fce89ac">00034</a> <a class="code" href="vfs__buffered__file_8c.html#a93b33fbbe4ac43469a7a2a784fce89ac">buffered_file_vfs_fclose_impl</a>(<a class="code" href="structVFSFile.html">VFSFile</a> * file)
<a name="l00035"></a>00035 {
<a name="l00036"></a>00036     g_return_val_if_fail(file != NULL, -1);
<a name="l00037"></a>00037 
<a name="l00038"></a>00038     <span class="keywordflow">if</span> (file-&gt;handle)
<a name="l00039"></a>00039     {
<a name="l00040"></a>00040         <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00041"></a>00041 
<a name="l00042"></a>00042         if (handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a> != NULL)
<a name="l00043"></a>00043             <a class="code" href="vfs_8c.html#aef1161802df682c9d8e0b68bce9f6988" title="Closes a VFS stream and destroys a VFSFile object.">vfs_fclose</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>);
<a name="l00044"></a>00044 
<a name="l00045"></a>00045         <a class="code" href="vfs_8c.html#aef1161802df682c9d8e0b68bce9f6988" title="Closes a VFS stream and destroys a VFSFile object.">vfs_fclose</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>);
<a name="l00046"></a>00046         g_free(handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab473bbc98b457c7e8461e8e5d1f81f8e" title="The memory for the buffer.">mem</a>);
<a name="l00047"></a>00047         g_free(handle);
<a name="l00048"></a>00048     }
<a name="l00049"></a>00049 
<a name="l00050"></a>00050     <span class="keywordflow">return</span> 0;
<a name="l00051"></a>00051 }
<a name="l00052"></a>00052 
<a name="l00053"></a><a class="code" href="vfs__buffered__file_8c.html#aa2358566335657965b21a915733ac03f">00053</a> gint64 <a class="code" href="vfs__buffered__file_8c.html#aa2358566335657965b21a915733ac03f">buffered_file_vfs_fread_impl</a> (<span class="keywordtype">void</span> * i_ptr, gint64 size, gint64 nmemb,
<a name="l00054"></a>00054  <a class="code" href="structVFSFile.html">VFSFile</a> * file)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00057"></a>00057 
<a name="l00058"></a>00058     <span class="comment">/* is this request within the buffered area, or should we switch to</span>
<a name="l00059"></a>00059 <span class="comment">     * an FD? --nenolod</span>
<a name="l00060"></a>00060 <span class="comment">     */</span>
<a name="l00061"></a>00061     if (handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> == FALSE &amp;&amp;
<a name="l00062"></a>00062         (<a class="code" href="vfs_8c.html#a6742c6fcc4618803004c00ecd773efcf" title="Returns the current position in the VFS stream&amp;#39;s buffer.">vfs_ftell</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>)) + (size * nmemb) &gt;
<a name="l00063"></a>00063         ((<a class="code" href="structVFSBuffer.html" title="Private data for the VFS memorybuffer class.">VFSBuffer</a> *) handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>-&gt;handle)-&gt;size)
<a name="l00064"></a>00064     {
<a name="l00065"></a>00065         <span class="keywordflow">if</span> (<a class="code" href="vfs_8c.html#afa299d74abcbf03120ba174b8673a7a0" title="Performs a seek in given VFS stream.">vfs_fseek</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>, <a class="code" href="vfs_8c.html#a6742c6fcc4618803004c00ecd773efcf" title="Returns the current position in the VFS stream&amp;#39;s buffer.">vfs_ftell</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>), SEEK_SET))
<a name="l00066"></a>00066             <span class="keywordflow">return</span> 0;
<a name="l00067"></a>00067         handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> = TRUE;
<a name="l00068"></a>00068     }
<a name="l00069"></a>00069 
<a name="l00070"></a>00070     <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#af6053b3415c8cee9443c181278bdf630" title="Reads from a VFS stream.">vfs_fread</a>(i_ptr, size, nmemb, handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> == TRUE ? handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a> : handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>);
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 
<a name="l00073"></a><a class="code" href="vfs__buffered__file_8c.html#a9192e7d2f132eda2e0c1e54d5d6c4539">00073</a> gint64 <a class="code" href="vfs__buffered__file_8c.html#a9192e7d2f132eda2e0c1e54d5d6c4539">buffered_file_vfs_fwrite_impl</a> (<span class="keyword">const</span> <span class="keywordtype">void</span> * i_ptr, gint64 size, gint64
<a name="l00074"></a>00074  nmemb, <a class="code" href="structVFSFile.html">VFSFile</a> * file)
<a name="l00075"></a>00075 {
<a name="l00076"></a>00076     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00077"></a>00077 
<a name="l00078"></a>00078     <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#a79bd59f08edb6cab002a6194ec4b4e24" title="Writes to a VFS stream.">vfs_fwrite</a>(i_ptr, size, nmemb, handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>);
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080 
<a name="l00081"></a>00081 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a>
<a name="l00082"></a><a class="code" href="vfs__buffered__file_8c.html#a15aa3931648d46b3132aaa9d36071ab0">00082</a> <a class="code" href="vfs__buffered__file_8c.html#a15aa3931648d46b3132aaa9d36071ab0">buffered_file_vfs_getc_impl</a>(<a class="code" href="structVFSFile.html">VFSFile</a> *stream)
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) stream-&gt;handle;
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <span class="comment">/* is this request within the buffered area, or should we switch to</span>
<a name="l00087"></a>00087 <span class="comment">     * an FD? --nenolod</span>
<a name="l00088"></a>00088 <span class="comment">     */</span>
<a name="l00089"></a>00089     if ((<a class="code" href="vfs_8c.html#a6742c6fcc4618803004c00ecd773efcf" title="Returns the current position in the VFS stream&amp;#39;s buffer.">vfs_ftell</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>)) + 1 &gt;
<a name="l00090"></a>00090         ((<a class="code" href="structVFSBuffer.html" title="Private data for the VFS memorybuffer class.">VFSBuffer</a> *) handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>-&gt;handle)-&gt;size)
<a name="l00091"></a>00091     {
<a name="l00092"></a>00092         <span class="keywordflow">if</span> (<a class="code" href="vfs_8c.html#afa299d74abcbf03120ba174b8673a7a0" title="Performs a seek in given VFS stream.">vfs_fseek</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>, <a class="code" href="vfs_8c.html#a6742c6fcc4618803004c00ecd773efcf" title="Returns the current position in the VFS stream&amp;#39;s buffer.">vfs_ftell</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>), SEEK_SET))
<a name="l00093"></a>00093             <span class="keywordflow">return</span> EOF;
<a name="l00094"></a>00094         handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> = TRUE;
<a name="l00095"></a>00095     }
<a name="l00096"></a>00096 
<a name="l00097"></a>00097     <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#af59728870b30677c8693cb82345eb8ea" title="Reads a character from a VFS stream.">vfs_getc</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> == TRUE ? handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a> : handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>);
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a>
<a name="l00101"></a><a class="code" href="vfs__buffered__file_8c.html#a78814e6a6acc9b93fc2e0c50dd2af16f">00101</a> <a class="code" href="vfs__buffered__file_8c.html#a78814e6a6acc9b93fc2e0c50dd2af16f">buffered_file_vfs_ungetc_impl</a>(<a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> c, <a class="code" href="structVFSFile.html">VFSFile</a> *stream)
<a name="l00102"></a>00102 {
<a name="l00103"></a>00103     <span class="keywordflow">return</span> -1;
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a>
<a name="l00107"></a><a class="code" href="vfs__buffered__file_8c.html#ace8e04793d9bce6524f5f52e1b973a8d">00107</a> <a class="code" href="vfs__buffered__file_8c.html#ace8e04793d9bce6524f5f52e1b973a8d">buffered_file_vfs_fseek_impl</a>(<a class="code" href="structVFSFile.html">VFSFile</a> * file,
<a name="l00108"></a>00108           gint64 offset,
<a name="l00109"></a>00109           <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a> whence)
<a name="l00110"></a>00110 {
<a name="l00111"></a>00111     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00112"></a>00112 
<a name="l00113"></a>00113     if (<a class="code" href="vfs_8c.html#afa299d74abcbf03120ba174b8673a7a0" title="Performs a seek in given VFS stream.">vfs_fseek</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>, offset, whence))
<a name="l00114"></a>00114         <span class="keywordflow">return</span> -1;
<a name="l00115"></a>00115 
<a name="l00116"></a>00116     <span class="keywordflow">switch</span>(whence)
<a name="l00117"></a>00117     {
<a name="l00118"></a>00118         <span class="keywordflow">case</span> SEEK_END:
<a name="l00119"></a>00119             handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> = TRUE;
<a name="l00120"></a>00120             <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#afa299d74abcbf03120ba174b8673a7a0" title="Performs a seek in given VFS stream.">vfs_fseek</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>, offset, whence);
<a name="l00121"></a>00121         <span class="keywordflow">case</span> SEEK_CUR:
<a name="l00122"></a>00122             <span class="keywordflow">if</span> (<a class="code" href="vfs_8c.html#a6742c6fcc4618803004c00ecd773efcf" title="Returns the current position in the VFS stream&amp;#39;s buffer.">vfs_ftell</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>) + offset &gt;= ((<a class="code" href="structVFSBuffer.html" title="Private data for the VFS memorybuffer class.">VFSBuffer</a> *) handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>-&gt;handle)-&gt;size)
<a name="l00123"></a>00123             {
<a name="l00124"></a>00124                 handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> = TRUE;
<a name="l00125"></a>00125                 <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#afa299d74abcbf03120ba174b8673a7a0" title="Performs a seek in given VFS stream.">vfs_fseek</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>, offset, whence);
<a name="l00126"></a>00126             }
<a name="l00127"></a>00127             <span class="keywordflow">else</span>
<a name="l00128"></a>00128             {
<a name="l00129"></a>00129                 gint64 noff;
<a name="l00130"></a>00130 
<a name="l00131"></a>00131                 handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> = FALSE;
<a name="l00132"></a>00132                 noff = ((<a class="code" href="structVFSBuffer.html" title="Private data for the VFS memorybuffer class.">VFSBuffer</a> *) handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>-&gt;handle)-&gt;size - (<a class="code" href="vfs_8c.html#a6742c6fcc4618803004c00ecd773efcf" title="Returns the current position in the VFS stream&amp;#39;s buffer.">vfs_ftell</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>) + offset);
<a name="l00133"></a>00133                 <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#afa299d74abcbf03120ba174b8673a7a0" title="Performs a seek in given VFS stream.">vfs_fseek</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>, noff, whence);
<a name="l00134"></a>00134             }
<a name="l00135"></a>00135             <span class="keywordflow">break</span>;
<a name="l00136"></a>00136         <span class="keywordflow">case</span> SEEK_SET:
<a name="l00137"></a>00137         <span class="keywordflow">default</span>:
<a name="l00138"></a>00138             <span class="keywordflow">if</span> (offset &gt; ((<a class="code" href="structVFSBuffer.html" title="Private data for the VFS memorybuffer class.">VFSBuffer</a> *) handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>-&gt;handle)-&gt;size)
<a name="l00139"></a>00139             {
<a name="l00140"></a>00140                 handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> = TRUE;
<a name="l00141"></a>00141                 <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#afa299d74abcbf03120ba174b8673a7a0" title="Performs a seek in given VFS stream.">vfs_fseek</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>, offset, whence);
<a name="l00142"></a>00142             }
<a name="l00143"></a>00143             <span class="keywordflow">else</span>
<a name="l00144"></a>00144             {
<a name="l00145"></a>00145                 handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> = FALSE;
<a name="l00146"></a>00146                 <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#afa299d74abcbf03120ba174b8673a7a0" title="Performs a seek in given VFS stream.">vfs_fseek</a> (handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>, offset, whence);
<a name="l00147"></a>00147             }
<a name="l00148"></a>00148             <span class="keywordflow">break</span>;
<a name="l00149"></a>00149     }
<a name="l00150"></a>00150     <span class="keywordflow">return</span> 0;
<a name="l00151"></a>00151 }
<a name="l00152"></a>00152 
<a name="l00153"></a>00153 <span class="keywordtype">void</span>
<a name="l00154"></a><a class="code" href="vfs__buffered__file_8c.html#ade3d9705125e78aee113c1e7eb36139a">00154</a> <a class="code" href="vfs__buffered__file_8c.html#ade3d9705125e78aee113c1e7eb36139a">buffered_file_vfs_rewind_impl</a>(<a class="code" href="structVFSFile.html">VFSFile</a> * file)
<a name="l00155"></a>00155 {
<a name="l00156"></a>00156     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00157"></a>00157 
<a name="l00158"></a>00158     <a class="code" href="vfs_8c.html#ae83d82ab649ac5c2ca47d377c9ff4138" title="Rewinds a VFS stream.">vfs_rewind</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>);
<a name="l00159"></a>00159     <a class="code" href="vfs_8c.html#ae83d82ab649ac5c2ca47d377c9ff4138" title="Rewinds a VFS stream.">vfs_rewind</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>);
<a name="l00160"></a>00160     handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> = FALSE;
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 gint64
<a name="l00164"></a><a class="code" href="vfs__buffered__file_8c.html#afebe13bd88854880ba724c13152e4da3">00164</a> <a class="code" href="vfs__buffered__file_8c.html#afebe13bd88854880ba724c13152e4da3">buffered_file_vfs_ftell_impl</a>(<a class="code" href="structVFSFile.html">VFSFile</a> * file)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00167"></a>00167 
<a name="l00168"></a>00168     <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#a6742c6fcc4618803004c00ecd773efcf" title="Returns the current position in the VFS stream&amp;#39;s buffer.">vfs_ftell</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> == TRUE ? handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a> : handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>);
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 <a class="code" href="configdb-api_8h.html#a3ac4dad7ee7fd2890139bff9a134ee9a">gboolean</a>
<a name="l00172"></a><a class="code" href="vfs__buffered__file_8c.html#a48c331b6fb4111d80d415704810aa177">00172</a> <a class="code" href="vfs__buffered__file_8c.html#a48c331b6fb4111d80d415704810aa177">buffered_file_vfs_feof_impl</a>(<a class="code" href="structVFSFile.html">VFSFile</a> * file)
<a name="l00173"></a>00173 {
<a name="l00174"></a>00174     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00175"></a>00175 
<a name="l00176"></a>00176     <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#a08c8a6aed713546f36413c8ed1c72b4f" title="Returns whether or not the VFS stream has reached EOF.">vfs_feof</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#a454c3aa9cde1784e97c0ab8484b79a2e" title="Whether to use the live FD or the buffer.">which</a> == TRUE ? handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a> : handle-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a>);
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178 
<a name="l00179"></a>00179 <a class="code" href="misc-api_8h.html#acf599c059f43e0cca83145eb6b0c93cd">gint</a>
<a name="l00180"></a><a class="code" href="vfs__buffered__file_8c.html#a6457a792055f1910dee9a5d973677e1f">00180</a> <a class="code" href="vfs__buffered__file_8c.html#a6457a792055f1910dee9a5d973677e1f">buffered_file_vfs_truncate_impl</a> (<a class="code" href="structVFSFile.html">VFSFile</a> * file, gint64 size)
<a name="l00181"></a>00181 {
<a name="l00182"></a>00182     <span class="keywordflow">return</span> 0;
<a name="l00183"></a>00183 }
<a name="l00184"></a>00184 
<a name="l00185"></a>00185 gint64
<a name="l00186"></a><a class="code" href="vfs__buffered__file_8c.html#afec60ae05dbd835de9dcd5951492d9b2">00186</a> <a class="code" href="vfs__buffered__file_8c.html#afec60ae05dbd835de9dcd5951492d9b2">buffered_file_vfs_fsize_impl</a>(<a class="code" href="structVFSFile.html">VFSFile</a> * file)
<a name="l00187"></a>00187 {
<a name="l00188"></a>00188     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00189"></a>00189 
<a name="l00190"></a>00190     <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#a7b06817cffbf1040dc5f7e65b5af3db0" title="Returns size of the file.">vfs_fsize</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>);
<a name="l00191"></a>00191 }
<a name="l00192"></a>00192 
<a name="l00193"></a>00193 gchar *
<a name="l00194"></a><a class="code" href="vfs__buffered__file_8c.html#ae2b5545cc0dc1d20e6186502b8e255e2">00194</a> <a class="code" href="vfs__buffered__file_8c.html#ae2b5545cc0dc1d20e6186502b8e255e2">buffered_file_vfs_metadata_impl</a>(<a class="code" href="structVFSFile.html">VFSFile</a> * file, <span class="keyword">const</span> gchar * field)
<a name="l00195"></a>00195 {
<a name="l00196"></a>00196     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *handle = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) file-&gt;handle;
<a name="l00197"></a>00197 
<a name="l00198"></a>00198     <span class="keywordflow">return</span> <a class="code" href="vfs_8c.html#acbd26807b5b752558de0a288b9fa66ac" title="Returns metadata about the stream.">vfs_get_metadata</a>(handle-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>, field);
<a name="l00199"></a>00199 }
<a name="l00200"></a>00200 
<a name="l00201"></a><a class="code" href="vfs__buffered__file_8c.html#aeeddbe2874cc19022f40ac6f6413fc9b">00201</a> <a class="code" href="structVFSConstructor.html">VFSConstructor</a> <a class="code" href="vfs__buffered__file_8c.html#aeeddbe2874cc19022f40ac6f6413fc9b">buffered_file_const</a> = {
<a name="l00202"></a>00202         NULL,                   <span class="comment">// not a normal VFS class</span>
<a name="l00203"></a>00203         <a class="code" href="vfs__buffered__file_8c.html#aa2f38f9d8e6ae969cad936708278681f">buffered_file_vfs_fopen_impl</a>,
<a name="l00204"></a>00204         <a class="code" href="vfs__buffered__file_8c.html#a93b33fbbe4ac43469a7a2a784fce89ac">buffered_file_vfs_fclose_impl</a>,
<a name="l00205"></a>00205         <a class="code" href="vfs__buffered__file_8c.html#aa2358566335657965b21a915733ac03f">buffered_file_vfs_fread_impl</a>,
<a name="l00206"></a>00206         <a class="code" href="vfs__buffered__file_8c.html#a9192e7d2f132eda2e0c1e54d5d6c4539">buffered_file_vfs_fwrite_impl</a>,
<a name="l00207"></a>00207         <a class="code" href="vfs__buffered__file_8c.html#a15aa3931648d46b3132aaa9d36071ab0">buffered_file_vfs_getc_impl</a>,
<a name="l00208"></a>00208         <a class="code" href="vfs__buffered__file_8c.html#a78814e6a6acc9b93fc2e0c50dd2af16f">buffered_file_vfs_ungetc_impl</a>,
<a name="l00209"></a>00209         <a class="code" href="vfs__buffered__file_8c.html#ace8e04793d9bce6524f5f52e1b973a8d">buffered_file_vfs_fseek_impl</a>,
<a name="l00210"></a>00210         <a class="code" href="vfs__buffered__file_8c.html#ade3d9705125e78aee113c1e7eb36139a">buffered_file_vfs_rewind_impl</a>,
<a name="l00211"></a>00211         <a class="code" href="vfs__buffered__file_8c.html#afebe13bd88854880ba724c13152e4da3">buffered_file_vfs_ftell_impl</a>,
<a name="l00212"></a>00212         <a class="code" href="vfs__buffered__file_8c.html#a48c331b6fb4111d80d415704810aa177">buffered_file_vfs_feof_impl</a>,
<a name="l00213"></a>00213         <a class="code" href="vfs__buffered__file_8c.html#a6457a792055f1910dee9a5d973677e1f">buffered_file_vfs_truncate_impl</a>,
<a name="l00214"></a>00214         <a class="code" href="vfs__buffered__file_8c.html#afec60ae05dbd835de9dcd5951492d9b2">buffered_file_vfs_fsize_impl</a>,
<a name="l00215"></a>00215         <a class="code" href="vfs__buffered__file_8c.html#ae2b5545cc0dc1d20e6186502b8e255e2">buffered_file_vfs_metadata_impl</a>
<a name="l00216"></a>00216 };
<a name="l00217"></a>00217 
<a name="l00224"></a>00224 <a class="code" href="structVFSFile.html">VFSFile</a> *
<a name="l00225"></a><a class="code" href="vfs__buffered__file_8h.html#ae4d7145f03a4f283772356ffe8a491f0">00225</a> <a class="code" href="vfs__buffered__file_8c.html#ae4d7145f03a4f283772356ffe8a491f0" title="Creates a VFSBufferedFile.">vfs_buffered_file_new_from_uri</a>(<span class="keyword">const</span> gchar *uri)
<a name="l00226"></a>00226 {
<a name="l00227"></a>00227     <a class="code" href="structVFSFile.html">VFSFile</a> *handle;
<a name="l00228"></a>00228     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *fd;
<a name="l00229"></a>00229     gsize sz;
<a name="l00230"></a>00230 
<a name="l00231"></a>00231     g_return_val_if_fail(uri != NULL, NULL);
<a name="l00232"></a>00232 
<a name="l00233"></a>00233     handle = g_new0(<a class="code" href="structVFSFile.html">VFSFile</a>, 1);
<a name="l00234"></a>00234     fd = g_new0(<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a>, 1);
<a name="l00235"></a>00235     fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab473bbc98b457c7e8461e8e5d1f81f8e" title="The memory for the buffer.">mem</a> = g_malloc0(128000);
<a name="l00236"></a>00236     fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a> = <a class="code" href="vfs_8c.html#a8b782c3531a5a5c4526232c3130a86de" title="Opens a stream from a VFS transport using one of the registered VFSConstructor handlers.">vfs_fopen</a>(uri, <span class="stringliteral">&quot;rb&quot;</span>);
<a name="l00237"></a>00237 
<a name="l00238"></a>00238     <span class="keywordflow">if</span> (fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a> == NULL)
<a name="l00239"></a>00239     {
<a name="l00240"></a>00240         g_free(fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab473bbc98b457c7e8461e8e5d1f81f8e" title="The memory for the buffer.">mem</a>);
<a name="l00241"></a>00241         g_free(fd);
<a name="l00242"></a>00242         g_free(handle);
<a name="l00243"></a>00243 
<a name="l00244"></a>00244         <span class="keywordflow">return</span> NULL;
<a name="l00245"></a>00245     }
<a name="l00246"></a>00246 
<a name="l00247"></a>00247     sz = <a class="code" href="vfs_8c.html#af6053b3415c8cee9443c181278bdf630" title="Reads from a VFS stream.">vfs_fread</a>(fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab473bbc98b457c7e8461e8e5d1f81f8e" title="The memory for the buffer.">mem</a>, 1, 128000, fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>);
<a name="l00248"></a>00248     <a class="code" href="vfs_8c.html#ae83d82ab649ac5c2ca47d377c9ff4138" title="Rewinds a VFS stream.">vfs_rewind</a>(fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>);
<a name="l00249"></a>00249 
<a name="l00250"></a>00250     <span class="keywordflow">if</span> (!sz)
<a name="l00251"></a>00251     {
<a name="l00252"></a>00252         <a class="code" href="vfs_8c.html#aef1161802df682c9d8e0b68bce9f6988" title="Closes a VFS stream and destroys a VFSFile object.">vfs_fclose</a>(fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>);
<a name="l00253"></a>00253         g_free(fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab473bbc98b457c7e8461e8e5d1f81f8e" title="The memory for the buffer.">mem</a>);
<a name="l00254"></a>00254         g_free(fd);
<a name="l00255"></a>00255         g_free(handle);
<a name="l00256"></a>00256 
<a name="l00257"></a>00257         <span class="keywordflow">return</span> NULL;
<a name="l00258"></a>00258     }
<a name="l00259"></a>00259 
<a name="l00260"></a>00260     fd-&gt;<a class="code" href="structVFSBufferedFile.html#a05481e5ed6c9d6895894cf0d6f3df581" title="First 32kb read from the FD.">buffer</a> = <a class="code" href="vfs__buffer_8c.html#a9b0eda6c1b2f1174d780034b6e7a0a04" title="Creates a VFS buffer for reading/writing to a memory segment.">vfs_buffer_new</a>(fd-&gt;<a class="code" href="structVFSBufferedFile.html#ab473bbc98b457c7e8461e8e5d1f81f8e" title="The memory for the buffer.">mem</a>, sz);
<a name="l00261"></a>00261 
<a name="l00262"></a>00262     handle-&gt;handle = fd;
<a name="l00263"></a>00263     handle-&gt;base = &amp;<a class="code" href="vfs__buffered__file_8c.html#aeeddbe2874cc19022f40ac6f6413fc9b">buffered_file_const</a>;
<a name="l00264"></a>00264     handle-&gt;uri = g_strdup(uri);
<a name="l00265"></a>00265     handle-&gt;ref = 1;
<a name="l00266"></a>00266 
<a name="l00267"></a>00267     <span class="keywordflow">return</span> handle;
<a name="l00268"></a>00268 }
<a name="l00269"></a>00269 
<a name="l00274"></a>00274 <a class="code" href="structVFSFile.html">VFSFile</a> *
<a name="l00275"></a><a class="code" href="vfs__buffered__file_8h.html#a59070df88010bb7a202387de11c3b56f">00275</a> <a class="code" href="vfs__buffered__file_8c.html#a59070df88010bb7a202387de11c3b56f">vfs_buffered_file_release_live_fd</a>(<a class="code" href="structVFSFile.html">VFSFile</a> *fd)
<a name="l00276"></a>00276 {
<a name="l00277"></a>00277     <a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *file = (<a class="code" href="structVFSBufferedFile.html" title="Private data for the VFS memorybuffer class.">VFSBufferedFile</a> *) fd;
<a name="l00278"></a>00278     <a class="code" href="structVFSFile.html">VFSFile</a> *out;
<a name="l00279"></a>00279 
<a name="l00280"></a>00280     g_return_val_if_fail(file != NULL, NULL);
<a name="l00281"></a>00281 
<a name="l00282"></a>00282     out = file-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a>;
<a name="l00283"></a>00283     file-&gt;<a class="code" href="structVFSBufferedFile.html#ab1731d453b6e338f118b35128212af19" title="VFS handle for the active FD.">fd</a> = NULL;
<a name="l00284"></a>00284 
<a name="l00285"></a>00285     <a class="code" href="vfs_8c.html#aef1161802df682c9d8e0b68bce9f6988" title="Closes a VFS stream and destroys a VFSFile object.">vfs_fclose</a>(fd);
<a name="l00286"></a>00286 
<a name="l00287"></a>00287     <span class="keywordflow">return</span> out;
<a name="l00288"></a>00288 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Sun Apr 17 2011 for Audacious by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>