source: rtems/c/src/lib/libc/truncate.c @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 785 bytes
Line 
1/*
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$
16 */
17
18#include <unistd.h>
19#include <errno.h>
20#include <fcntl.h>
21
22int 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
Note: See TracBrowser for help on using the repository browser.