Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/ftruncate.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/ftruncate.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/ftruncate.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/ftruncate.html on line 8
Truncate a file
#include <unistd.h>
int ftruncate( int fildes,
off_t length );
int ftruncate64( int fildes,
off64_t length );
- fildes
- The descriptor for the file that you want to truncate.
- length
- The length that you want the file to be, in bytes.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
These functions cause the file referenced by
fildes to have a size of length bytes.
If the size of the file previously exceeded length, the extra
data is discarded (this is similar to using the F_FREESP
option with fcntl()).
If the size of the file was previously shorter than length,
the file size is extended with NUL characters (similar to the
F_ALLOCSP option to fcntl()).
The value of the seek pointer isn't modified by a call to
ftruncate().
Upon successful completion, the ftruncate() function
marks the st_ctime and st_mtime fields of the
file for update. If the ftruncate() function is
unsuccessful, the file is unaffected.
Zero for success, or -1 if an error occurred
(errno is set).
- EBADF
- The fildes argument isn't a valid file descriptor.
- EFBIG
- The file is a regular file and length is greater than the offset
maximum associated with the file.
- EINTR
- A signal was caught during the call to
ftruncate().
- EINVAL
- The fildes argument doesn't refer to a file on
which this operation is possible, the filedes argument
isn't open for writing or the length argument is less than
the minimum file size for the specified filesystem.
- EIO
- An I/O error occurred while reading from or writing to the
filesystem.
- ENOSYS
- The ftruncate() function isn't implemented for the filesystem specified
by filedes.
- ENOTSUP
- The ftruncate() function is implemented for the specified
filesystem, but the specific operation (F_ALLOCSP or
F_FREESP; see
fcntl()) isn't supported.
- EROFS
- The file resides on a read-only filesystem.
ftruncate() is
POSIX 1003.1;
ftruncate64() is
Large-file support
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
mmap(),
open(),
shm_open(),
truncate()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/ftruncate.html on line 198
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/ftruncate.html on line 198