Branch: Tag:

2003-10-15

2003-10-15 16:00:37 by Martin Stjernholm <mast@lysator.liu.se>

Improved the docs a bit.

Rev: src/modules/files/file.c:1.295

124:   <dd class='body--doc'><p>Close a file or stream.</p>   <p> If direction is not specified, both the read and the write direction    will be closed. Otherwise only the directions specified will be closed.</p> + <p> An exception is thrown if an I/O error occurs.</p>   </dd> -  + <dt class='head--doc'>Returns</dt> + <dd class='body--doc'><p>Nonzero is returned if the file or stream wasn't open in the +  specified direction, zero otherwise.</p> + </dd>   <dt class='head--doc'>See also</dt>   <dd class='body--doc'><p><code>open()</code>, <code>open_socket()</code></p>   </dd></dl>
812:   <code><code class='datatype'>string</code> <b><span class='method'>read</span>(</b><code class='datatype'>int</code> <code class='argument'>len</code>, <code class='datatype'>bool</code> <code class='argument'>not_all</code><b>)</b></code></p></dd>      <dt class='head--doc'>Description</dt> - <dd class='body--doc'><p>Read data from a file or a string.</p> + <dd class='body--doc'><p>Read data from a file or a socket.</p>   <p> Attempts to read <code>len</code> bytes from the file, and return it as a -  string. If something goes wrong, zero is returned.</p> - <p> If a one is given as the second argument to <code>read()</code>, it will not try -  its best to read as many bytes as you have asked for, but will -  merely try to read as many bytes as the system read function will -  return. This mainly useful with stream devices which can return -  exactly one row or packet at a time.</p> +  string. Less than <code>len</code> bytes can be returned if end-of-file is +  encountered or, in the case it's a socket or pipe, it was closed +  from the other end.</p> + <p> If <code>not_all</code> is nonzero, <code>read()</code> will not try its best to read +  as many bytes as you have asked for, but will merely return as +  much as the system read function will return. This mainly useful +  with stream devices which can return exactly one row or packet at +  a time.</p> + <p> If something goes wrong and <code>not_all</code> is set, zero will be +  returned. If something goes wrong and <code>not_all</code> is not set, then +  either zero or a string shorter than <code>len</code> is returned.</p> + <p> If everything went fine, a call to <code>errno()</code> directly afterwards +  will return zero. That includes an end due to end-of-file or +  remote close.</p>   <p> If no arguments are given, <code>read()</code> will read to the    end of the file/stream.</p>   </dd>