]>
Commit | Line | Data |
---|---|---|
082e680b MNI |
1 | /* Copyright (C) 2004 Manuel Novoa III <[email protected]> |
2 | * | |
3 | * GNU Library General Public License (LGPL) version 2 or later. | |
4 | * | |
5 | * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. | |
6 | */ | |
7 | ||
8 | #include "_stdio.h" | |
9 | ||
10 | #include <unistd.h> | |
11 | #include <errno.h> | |
12 | ||
13 | /* SUSv3 states: | |
14 | * If path does not name a directory, remove(path) shall be equivalent | |
15 | * to unlink(path). If path names a directory, remove(path) shall be | |
16 | * equivalent to rmdir(path). | |
17 | */ | |
18 | ||
19 | int remove(register const char *filename) | |
20 | { | |
21 | int saved_errno = errno; | |
22 | int rv; | |
23 | ||
24 | if (((rv = rmdir(filename)) < 0) && (errno == ENOTDIR)) { | |
25 | __set_errno(saved_errno); /* Need to restore errno. */ | |
26 | rv = unlink(filename); | |
27 | } | |
28 | return rv; | |
29 | } |