xref: /minix3/lib/libc/stdio/remove.c (revision b6cbf7203b080219de306404f8022a65b7884f33)
1 /*
2  * remove.c - remove a file
3  */
4 /* $Header$ */
5 
6 #include	<stdio.h>
7 #include	<errno.h>
8 
9 int _rmdir(const char *path);
10 int _unlink(const char *path);
11 
12 int
13 remove(const char *filename) {
14 	int saved_errno, retval;
15 
16 	saved_errno = errno;
17 
18 	retval = _rmdir(filename);
19 
20 	if (retval == -1 && errno == ENOTDIR) {
21 		errno = saved_errno;
22 
23 		retval = _unlink(filename);
24 	}
25 
26 	return retval;
27 }
28