home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / CNews / Source / libbsd42 / getcwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-12  |  425 b   |  31 lines

  1. /*
  2.  * SystemV getcwd simulation on 4.2BSD
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <sys/param.h>
  8.  
  9. /* imports from libc */
  10. extern char *getwd();
  11.  
  12. char *
  13. getcwd(path, size)
  14. register char *path;
  15. int size;
  16. {
  17.     if (size >= MAXPATHLEN)
  18.         return getwd(path);
  19.     else {
  20.         char wd[MAXPATHLEN];
  21.  
  22.         if (getwd(wd) == 0)
  23.             return 0;
  24.         else {
  25.             (void) strncpy(path, wd, size-1);
  26.             path[size-1] = '\0';
  27.             return path;
  28.         }
  29.     }
  30. }
  31.