home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / LIBSRC.ZOO / libsrc / local / unlink.c < prev    next >
Text File  |  1992-02-29  |  927b  |  59 lines

  1. #define INCL_DOSFILEMGR
  2. #define INCL_DOSERRORS
  3. #include <os2.h>
  4. #include <errno.h>
  5.  
  6. ULONG Dos32Delete() asm ("Dos32Delete");
  7.  
  8. int unlink (char *path)
  9. {
  10.    ULONG rc;
  11.  
  12.    if (path == 0)
  13.    {
  14.       errno = EFAULT;
  15.       return (-1);
  16.    }
  17.  
  18.    rc = Dos32Delete (path);
  19.  
  20.    if (rc)
  21.    {
  22.       if (rc == ERROR_FILE_NOT_FOUND)
  23.       {
  24.          errno = ENOENT;
  25.          return (-1);
  26.       }
  27.  
  28.       if (rc == ERROR_PATH_NOT_FOUND)
  29.       {
  30.          errno = ENOTDIR;
  31.          return (-1);
  32.       }
  33.  
  34.       if (rc == ERROR_ACCESS_DENIED)
  35.       {
  36.          errno = EACCES;
  37.          return (-1);
  38.       }
  39.  
  40.       if (rc == ERROR_INVALID_PARAMETER)
  41.       {
  42.          errno = EINVAL;
  43.          return (-1);
  44.       }
  45.  
  46.       if (rc == ERROR_FILENAME_EXCED_RANGE)
  47.       {
  48.          errno = ENAMETOOLONG;
  49.          return (-1);
  50.       }
  51.  
  52.       errno = EIO;
  53.       return (-1);
  54.    }
  55.  
  56.    return (0);
  57. }
  58.  
  59.