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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [truncate.c] - Blame information for rev 1774

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

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  truncate.c,v 1.3 2001/01/08 18:26:44 joel Exp
16
 */
17
 
18
#if HAVE_CONFIG_H
19
#include "config.h"
20
#endif
21
 
22
#include <unistd.h>
23
#include <errno.h>
24
#include <fcntl.h>
25
 
26
int truncate(
27
  const char  *path,
28
  off_t        length
29
)
30
{
31
  int status;
32
  int fd;
33
 
34
  fd = open( path, O_WRONLY );
35
  if ( fd == -1 )
36
    return -1;
37
 
38
  status = ftruncate( fd, length );
39
 
40
  (void) close( fd );
41
 
42
  return status;
43
}
44
 

powered by: WebSVN 2.1.0

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