remove.c 467 B

1234567891011121314151617181920212223
  1. /* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
  2. * This file is part of the Linux-8086 C library and is distributed
  3. * under the GNU Library General Public License.
  4. */
  5. #include <unistd.h>
  6. #include <string.h>
  7. #include <sys/types.h>
  8. #include <errno.h>
  9. int remove(src)
  10. __const char *src;
  11. {
  12. extern int errno;
  13. int er = errno;
  14. int rv = unlink(src);
  15. if (rv < 0 && errno == EISDIR)
  16. rv = rmdir(src);
  17. if (rv >= 0)
  18. errno = er;
  19. return rv;
  20. }