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