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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [truncate.c] - Blame information for rev 596

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

Line No. Rev Author Line
1 30 unneback
/*
2
 *  truncate() - Truncate a File to the Specified Length
3
 *
4
 *  This routine is not defined in the POSIX 1003.1b standard but is
5
 *  commonly supported on most UNIX and POSIX systems.  It is provided
6
 *  for compatibility.
7
 *
8
 *  COPYRIGHT (c) 1989-1999.
9
 *  On-Line Applications Research Corporation (OAR).
10
 *
11
 *  The license and distribution terms for this file may be
12
 *  found in the file LICENSE in this distribution or at
13
 *  http://www.OARcorp.com/rtems/license.html.
14
 *
15
 *  $Id: truncate.c,v 1.2 2001-09-27 12:01:15 chris Exp $
16
 */
17
 
18
#include <unistd.h>
19
#include <errno.h>
20
#include <fcntl.h>
21
 
22
int truncate(
23
  const char  *path,
24
  off_t        length
25
)
26
{
27
  int status;
28
  int fd;
29
 
30
  fd = open( path, O_WRONLY );
31
  if ( fd == -1 )
32
    return -1;
33
 
34
  status = ftruncate( fd, length );
35
 
36
  (void) close( fd );
37
 
38
  return status;
39
}
40
 

powered by: WebSVN 2.1.0

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