source:
rtems/c/src/exec/libcsupport/src/rmdir.c
@
9c3fa30
Last change on this file since 9c3fa30 was 9c3fa30, checked in by Joel Sherrill <joel.sherrill@…>, on 09/28/00 at 20:19:23 | |
---|---|
|
|
File size: 1.4 KB |
Line | |
---|---|
1 | /* |
2 | * rmdir() - POSIX 1003.1b - 5.2.2 - Remove a Directory |
3 | * |
4 | * COPYRIGHT (c) 1989-1999. |
5 | * On-Line Applications Research Corporation (OAR). |
6 | * |
7 | * The license and distribution terms for this file may be |
8 | * found in the file LICENSE in this distribution or at |
9 | * http://www.OARcorp.com/rtems/license.html. |
10 | * |
11 | * $Id$ |
12 | */ |
13 | |
14 | #include <sys/types.h> |
15 | #include <fcntl.h> |
16 | #include <unistd.h> |
17 | #include <errno.h> |
18 | #include <stdlib.h> |
19 | |
20 | #include "libio_.h" |
21 | |
22 | int rmdir( |
23 | const char *pathname |
24 | ) |
25 | { |
26 | rtems_filesystem_location_info_t loc; |
27 | int result; |
28 | |
29 | /* |
30 | * Get the node where we wish to go. |
31 | */ |
32 | |
33 | result = rtems_filesystem_evaluate_path( pathname, 0, &loc, FALSE ); |
34 | if ( result != 0 ) |
35 | return -1; |
36 | |
37 | /* |
38 | * Verify you can remove this node as a directory. |
39 | */ |
40 | |
41 | if ( !loc.ops->node_type_h ){ |
42 | rtems_filesystem_freenode( &loc ); |
43 | set_errno_and_return_minus_one( ENOTSUP ); |
44 | } |
45 | |
46 | if ( (*loc.ops->node_type_h)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ){ |
47 | rtems_filesystem_freenode( &loc ); |
48 | set_errno_and_return_minus_one( ENOTDIR ); |
49 | } |
50 | |
51 | /* |
52 | * Use the filesystems rmnod to remove the node. |
53 | */ |
54 | |
55 | if ( !loc.handlers->rmnod_h ){ |
56 | rtems_filesystem_freenode( &loc ); |
57 | set_errno_and_return_minus_one( ENOTSUP ); |
58 | } |
59 | |
60 | result = (*loc.handlers->rmnod_h)( &loc ); |
61 | |
62 | rtems_filesystem_freenode( &loc ); |
63 | |
64 | return result; |
65 | } |
Note: See TracBrowser
for help on using the repository browser.