/****************************************************************************
 *
 * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/stdio/remove.c,v $
 * $Date: 2005/11/16 03:15:42 $
 * $Revision: 1.3 $
 * $State: Exp $
 * $Author: joty $
 *
 ***************************************************************************/

#include <stdio.h>
#include <unistd.h>
#include <errno.h>

int
remove (const char *file)
{
  int save_errno, status;

  /* Preserve errno.  */
  save_errno = errno;

  /* Try and delete the file.  */
  status = unlink (file);
  if (status == -1 && errno == EISDIR)
    {
      (void) __set_errno (save_errno);
      /* The pathname specifies a directory.  */
      status = rmdir (file);
    }
  return status;
}
