]> pd.if.org Git - pdclib/blob - functions/stdio/remove.c
Added FIXME
[pdclib] / 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 #include <stdio.h>
10
11 #ifndef REGTEST
12 #include <_PDCLIB_glue.h>
13
14 int remove( const char * filename )
15 {
16     /* TODO: Check open file list, flush and close file if open */
17     return _PDCLIB_remove( filename );
18 }
19
20 #endif
21
22 #ifdef TEST
23 /* TODO: Work around the following undef */
24 #undef SEEK_SET
25 #include <_PDCLIB_test.h>
26
27 #include <stdlib.h>
28 #include <string.h>
29
30 int main( void )
31 {
32     /* TODO: Extend to internal testing (buffer etc.) */
33     char filename[] = "touch testfile";
34     system( filename );
35     /* file is actually readable */
36     TESTCASE( fopen( filename + 6, "r" ) != NULL );
37     /* remove function does not return error */
38     TESTCASE( remove( filename + 6 ) == 0 );
39     /* file is no longer readable */
40     TESTCASE( fopen( filename + 6, "r" ) == NULL );
41     /* remove function does return error */
42     TESTCASE( remove( filename + 6 ) != 0 );
43     memcpy( filename, "mkdir", 5 );
44     /* create directory */
45     system( filename );
46     /* remove function does not return error */
47     TESTCASE( remove( filename + 6 ) == 0 );
48     /* remove function does return error */
49     TESTCASE( remove( filename + 6 ) != 0 );
50     return TEST_RESULTS;
51 }
52
53 #endif