home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume16 / pcomm2 / part04 / getcwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-09-14  |  387 b   |  24 lines

  1. /*
  2.  * Can you believe it???  Masscomps don't have a function to return the
  3.  * current working directory while in the AT&T universe!
  4.  */
  5.  
  6. #include <stdio.h>
  7.  
  8. char *
  9. getcwd(buf, size)
  10. char *buf;
  11. int size;
  12. {
  13.     FILE *pfp, *popen();
  14.  
  15.     if (!(pfp = popen("pwd", "r")))
  16.         return(".");
  17.  
  18.     fgets(buf, size, pfp);
  19.     pclose(pfp);
  20.                     /* zap the new line */
  21.     buf[strlen(buf)-1] = NULL;
  22.     return(buf);
  23. }
  24.