llvm.org GIT mirror llvm / 1981c2e
Add the remove() function from the C library. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24498 91177308-0d34-0410-b5e6-96231b3b80d8 John Criswell 13 years ago
1 changed file(s) with 46 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //===-- remove.c - The remove function for the LLVM libc Library --*- C -*-===//
1 //
2 // A lot of this code is ripped gratuitously from glibc and libiberty.
3 //
4 //===----------------------------------------------------------------------===//
5
6 /* ANSI C `remove' function to delete a file or directory. POSIX.1 version.
7 Copyright (C) 1995,96,97,2002 Free Software Foundation, Inc.
8 This file is part of the GNU C Library.
9
10 The GNU C Library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 The GNU C Library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with the GNU C Library; if not, write to the Free
22 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 02111-1307 USA. */
24
25 #include
26 #include
27 #include
28
29 int
30 remove (const char * file)
31 {
32 int save;
33
34 save = errno;
35 if (rmdir (file) == 0)
36 return 0;
37 else if (errno == ENOTDIR && unlink (file) == 0)
38 {
39 errno = (save);
40 return 0;
41 }
42
43 return -1;
44 }
45