ftruncate.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <html>
  2. <head>
  3. <title>ftruncate</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>ftruncate</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. ftruncate - set size of a file
  9. <h3>Library</h3>
  10. Standard C Library (libc, -lc)
  11. <h3>Synopsis</h3>
  12. #include &lt;unistd.h&gt;<br>
  13. <br>
  14. int<br>
  15. ftruncate(int <em>fd</em>, off_t <em>filesize</em>);
  16. <h3>Description</h3>
  17. ftruncate forcibly sets the size of the file referred to by
  18. <em>fd</em> to <em>filesize</em>. If this expands the file, the new
  19. data appears as if it is zero-filled. If this shrinks the file, the
  20. excess data is discarded.
  21. <p>
  22. The file must be open for write.
  23. <h3>Return Values</h3>
  24. On success, ftruncate returns 0. On error, -1 is returned, and
  25. <A HREF=errno.html>errno</A> is set according to the error
  26. encountered.
  27. <h3>Errors</h3>
  28. The following error codes should be returned under the conditions
  29. given. Other error codes may be returned for other errors not
  30. mentioned here.
  31. <blockquote><table width=90%>
  32. <td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
  33. <tr><td>EBADF</td> <td><em>fd</em> is not a valid file handle, or
  34. it is not open for writing.</td></tr>
  35. <tr><td>EIO</td> <td>A hard I/O error occurred.</td></tr>
  36. <tr><td>EFAULT</td> <td><em>buf</em> points to an invalid address.</td></tr>
  37. </table></blockquote>
  38. </body>
  39. </html>