getdirentry.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <html>
  2. <head>
  3. <title>getdirentry</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>getdirentry</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. getdirentry - read filename from directory
  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. getdirentry(int <em>fd</em>, char *<em>buf</em>, size_t <em>buflen</em>);
  16. <h3>Description</h3>
  17. getdirentry retrieves the next filename from a directory referred to
  18. by the file handle <em>filehandle</em>. The name is stored in
  19. <em>buf</em>, an area of size <em>buflen</em>. The length of of the
  20. name actually found is returned.
  21. <p>
  22. Note: this call behaves like read() - the name stored in <em>buf</em>
  23. is not null-terminated.
  24. <p>
  25. Which filename is the "next" is chosen based on the seek pointer
  26. associated with the file handle. The meaning of the seek pointer on a
  27. directory is defined by the filesystem in use and should not be
  28. interpreted - the only ways in which <A HREF=lseek.html>lseek</A>
  29. should be used are with SEEK_SET and an offset previously returned by
  30. lseek, or with any of SEEK_SET, SEEK_CUR, or SEEK_EOF with an offset
  31. of 0.
  32. <p>
  33. <h3>Return Values</h3>
  34. On success, getdirentry returns the length of the name transferred.
  35. On error, -1 is returned, and <A HREF=errno.html>errno</A> is set
  36. according to the error encountered.
  37. <h3>Errors</h3>
  38. <blockquote><table width=90%>
  39. <td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
  40. <tr><td>EBADF</td> <td><em>fd</em> is not a valid file handle.</td></tr>
  41. <tr><td>ENOTDIR</td> <td><em>fd</em> does not refer to a directory.</td></tr>
  42. <tr><td>EIO</td> <td>A hard I/O error occurred.</td></tr>
  43. <tr><td>EFAULT</td> <td><em>buf</em> points to an invalid address.</td></tr>
  44. </table></blockquote>
  45. </body>
  46. </html>