home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / libnix-0.8-src.lha / libnix-0.8 / sources / nix / extra / getcwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-17  |  371 b   |  23 lines

  1. #include <stdlib.h>
  2. #include <errno.h>
  3. #include <unistd.h>
  4. #ifdef __GNUC__
  5. #include <inline/dos.h>
  6. #endif
  7.  
  8. extern void __seterrno();
  9.  
  10. char *getcwd(char *buf,size_t size)
  11. {
  12.   if (buf!=NULL || (buf=(char *)malloc(size))!=NULL)
  13.   {
  14.     if (GetCurrentDirName(buf,(ULONG)size)==DOSFALSE)
  15.     {
  16.        __seterrno(); buf=NULL;
  17.     }
  18.   }
  19.   else
  20.     errno=ENOMEM;
  21.   return buf;
  22. }
  23.