getcwd.html 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <html>
  2. <head>
  3. <title>getcwd</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>getcwd</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. getcwd - get name of current working 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. char *<br>
  15. getcwd(char *<em>buf</em>, size_t <em>buflen</em>);
  16. <h3>Description</h3>
  17. The name of the current directory is computed and stored in
  18. <em>buf</em>, an area of size <em>buflen</em>. The resulting string is
  19. 0-terminated.
  20. <p>
  21. This call is a wrapper (for Unix compatibility) around the system call
  22. <A HREF=../syscall/__getcwd.html>__getcwd</A>.
  23. <p>
  24. Note, however, that the BSD extension whereby space is allocated with
  25. <A HREF=malloc.html>malloc</A> if <em>buf</em> is NULL is not supported.
  26. <h3>Return Values</h3>
  27. On success, getcwd returns <em>buf</em>.
  28. On error, NULL is returned, and <A HREF=errno.html>errno</A>
  29. is set according to the error encountered.
  30. <h3>Errors</h3>
  31. The following error codes should be returned under the conditions
  32. given. Other error codes may be returned for other errors not
  33. mentioned here.
  34. <blockquote><table width=90%>
  35. <td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
  36. <tr><td>ENOENT</td> <td>A component of the pathname no longer exists.</td></tr>
  37. <tr><td>EIO</td> <td>A hard I/O error occurred.</td></tr>
  38. <tr><td>EFAULT</td> <td><em>buf</em> points to an invalid address.</td></tr>
  39. </table></blockquote>
  40. </body>
  41. </html>