home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / LIBSRC.ZOO / libsrc / local / getcwd.c < prev    next >
Text File  |  1992-04-03  |  465b  |  30 lines

  1. #define INCL_DOSFILEMGR
  2. #include <os2.h>
  3. #include <errno.h>
  4.  
  5. ULONG Dos32QueryCurrentDir() asm ("Dos32QueryCurrentDir");
  6.  
  7. char *getcwd (char *buf, int size)
  8. {
  9.    char *tbuf = buf;
  10.    int tsize = size;
  11.    ULONG rc;
  12.  
  13.    if (tbuf == NULL)
  14.    {
  15.       tbuf = (char *) malloc (2048);
  16.       tsize = 2048;
  17.    }
  18.  
  19.    rc = Dos32QueryCurrentDir (0, tbuf, &tsize);
  20.  
  21.    if (rc)
  22.    {
  23.       errno = EIO;
  24.       return (NULL);
  25.    }
  26.  
  27.    return (tbuf);
  28. }
  29.  
  30.