]> pd.if.org Git - pdclib/blob - platform/example_cygwin/functions/stdio/remove.c
Addressed ticket #40 (non-standard errno values).
[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             /* See the comments on implementation-defined errno values in
28                <_PDCLIB_config.h>.
29             */
30             case EACCES:
31             case EFAULT:
32             case EIO:
33             case EISDIR:
34             case ELOOP:
35             case ENAMETOOLONG:
36             case ENOENT:
37             case ENOMEM:
38             case ENOTDIR:
39             case EPERM:
40             case EROFS:
41                 _PDCLIB_errno = _PDCLIB_ERROR;
42                 break;
43             default:
44                 /* This should be something like EUNKNOWN. */
45                 _PDCLIB_errno = _PDCLIB_ERROR;
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