source: trunk/libs/newlib/src/newlib/libc/stdio/remove.c @ 450

Last change on this file since 450 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.2 KB
Line 
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 * advertising materials, and 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/*
19FUNCTION
20<<remove>>---delete a file's name
21
22INDEX
23        remove
24INDEX
25        _remove_r
26
27SYNOPSIS
28        #include <stdio.h>
29        int remove(char *<[filename]>);
30
31        int _remove_r(struct _reent *<[reent]>, char *<[filename]>);
32
33DESCRIPTION
34Use <<remove>> to dissolve the association between a particular
35filename (the string at <[filename]>) and the file it represents.
36After calling <<remove>> with a particular filename, you will no
37longer be able to open the file by that name.
38
39In this implementation, you may use <<remove>> on an open file without
40error; existing file descriptors for the file will continue to access
41the file's data until the program using them closes the file.
42
43The alternate function <<_remove_r>> is a reentrant version.  The
44extra argument <[reent]> is a pointer to a reentrancy structure.
45
46RETURNS
47<<remove>> returns <<0>> if it succeeds, <<-1>> if it fails.
48
49PORTABILITY
50ANSI C requires <<remove>>, but only specifies that the result on
51failure be nonzero.  The behavior of <<remove>> when you call it on an
52open file may vary among implementations.
53
54Supporting OS subroutine required: <<unlink>>.
55*/
56
57#include <_ansi.h>
58#include <reent.h>
59#include <stdio.h>
60
61int
62_remove_r (struct _reent *ptr,
63       const char *filename)
64{
65  if (_unlink_r (ptr, filename) == -1)
66    return -1;
67
68  return 0;
69}
70
71#ifndef _REENT_ONLY
72
73int
74remove (const char *filename)
75{
76  return _remove_r (_REENT, filename);
77}
78
79#endif
Note: See TracBrowser for help on using the repository browser.