1 /*
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * and/or other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17
18 /*
19 FUNCTION
20 <<remove>>---delete a file's name
21
22 INDEX
23 remove
24 INDEX
25 _remove_r
26
27 SYNOPSIS
28 #include <stdio.h>
29 int remove(char *<[filename]>);
30
31 int remove( char *<[filename]>);
32
33 DESCRIPTION
34 Use <<remove>> to dissolve the association between a particular
35 filename (the string at <[filename]>) and the file it represents.
36 After calling <<remove>> with a particular filename, you will no
37 longer be able to open the file by that name.
38
39 In this implementation, you may use <<remove>> on an open file without
40 error; existing file descriptors for the file will continue to access
41 the file's data until the program using them closes the file.
42
43 The alternate function <<_remove_r>> is a reentrant version. The
44 extra argument <[reent]> is a pointer to a reentrancy structure.
45
46 RETURNS
47 <<remove>> returns <<0>> if it succeeds, <<-1>> if it fails.
48
49 PORTABILITY
50 ANSI C requires <<remove>>, but only specifies that the result on
51 failure be nonzero. The behavior of <<remove>> when you call it on an
52 open file may vary among implementations.
53
54 Supporting OS subroutine required: <<unlink>>.
55 */
56
57 #define _DEFAULT_SOURCE
58 #include <_ansi.h>
59 #include <stdio.h>
60 #include <unistd.h>
61
62 int
remove(const char * filename)63 remove (
64 const char *filename)
65 {
66 if (unlink (filename) == -1)
67 return -1;
68
69 return 0;
70 }
71