Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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