]> pd.if.org Git - pdclib/blob - platform/posix/functions/stdio/remove.c
PDCLib includes with quotes, not <>.
[pdclib] / platform / posix / functions / stdio / remove.c
1 /* remove( const char * )
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 /* This is an example implementation of remove() fit for use with POSIX kernels.
8 */
9
10 #include <stdio.h>
11
12 #ifndef REGTEST
13 #include "_PDCLIB_io.h"
14 #include <string.h>
15
16 extern FILE * _PDCLIB_filelist;
17
18 extern int unlink( const char * pathname );
19
20 int remove( const char * pathname )
21 {
22     FILE * current = _PDCLIB_filelist;
23     while ( current != NULL )
24     {
25         if ( ( current->filename != NULL ) && ( strcmp( current->filename, pathname ) == 0 ) )
26         {
27             return EOF;
28         }
29         current = current->next;
30     }
31     return unlink( pathname );
32 }
33
34 #endif
35
36 #ifdef TEST
37 #include "_PDCLIB_test.h"
38
39 int main( void )
40 {
41     /* Testing covered by ftell.c (and several others) */
42     return TEST_RESULTS;
43 }
44
45 #endif
46