OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [lib/] [libc/] [rmdir.c] - Blame information for rev 158

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 158 chris
/*
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: rmdir.c,v 1.1.1.1 2001-07-10 09:55:25 chris Exp $
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 ){
42
    rtems_filesystem_freenode( &loc );
43
    set_errno_and_return_minus_one( ENOTSUP );
44
  }
45
 
46
  if (  (*loc.ops->node_type)( &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 ){
56
    rtems_filesystem_freenode( &loc );
57
    set_errno_and_return_minus_one( ENOTSUP );
58
  }
59
 
60
  result =  (*loc.handlers->rmnod)( &loc );
61
 
62
  rtems_filesystem_freenode( &loc );
63
 
64
  return result;
65
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.