]> pd.if.org Git - pdclib/blob - platform/example_cygwin/functions/stdio/remove.c
0e66f4c65c6cb3124f51fcbc8105fe793174f405
[pdclib] / platform / example_cygwin / 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
16 #include "/usr/include/errno.h"
17
18 extern int unlink( const char * pathname );
19
20 int remove( const char * pathname )
21 {
22     int rc;
23     if ( ( rc = unlink( pathname ) ) == -1 )
24     {
25         switch ( errno )
26         {
27             /* These are the values possible on a Linux machine. Adapt the
28                values and their mapping to PDCLib errno values at will. (This
29                is an example implementation, so we keep it very simple.)
30             */
31             case EACCES:
32             case EFAULT:
33             case EIO:
34             case EISDIR:
35             case ELOOP:
36             case ENAMETOOLONG:
37             case ENOENT:
38             case ENOMEM:
39             case ENOTDIR:
40             case EPERM:
41             case EROFS:
42                 _PDCLIB_errno = _PDCLIB_EIO;
43                 break;
44             default:
45                 _PDCLIB_errno = _PDCLIB_EUNKNOWN;
46                 break;
47         }
48     }
49     return rc;
50 }
51
52 #endif
53
54 #ifdef TEST
55 #include <_PDCLIB_test.h>
56
57 int main( void )
58 {
59     /* Testing covered by ftell.c (and several others) */
60     return TEST_RESULTS;
61 }
62
63 #endif
64