Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdio / remove.c
blobd8dfdbd82a4401a4660b1d618156dadeda409296
1 /*
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
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.
19 FUNCTION
20 <<remove>>---delete a file's name
22 INDEX
23 remove
24 INDEX
25 _remove_r
27 SYNOPSIS
28 #include <stdio.h>
29 int remove(char *<[filename]>);
31 int _remove_r(struct _reent *<[reent]>, char *<[filename]>);
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.
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.
43 The alternate function <<_remove_r>> is a reentrant version. The
44 extra argument <[reent]> is a pointer to a reentrancy structure.
46 RETURNS
47 <<remove>> returns <<0>> if it succeeds, <<-1>> if it fails.
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.
54 Supporting OS subroutine required: <<unlink>>.
57 #include <_ansi.h>
58 #include <reent.h>
59 #include <stdio.h>
61 int
62 _remove_r (struct _reent *ptr,
63 const char *filename)
65 if (_unlink_r (ptr, filename) == -1)
66 return -1;
68 return 0;
71 #ifndef _REENT_ONLY
73 int
74 remove (const char *filename)
76 return _remove_r (_REENT, filename);
79 #endif