ftruncate64()--Truncate File (Large File Enabled)
Syntax
#include <unistd.h> int ftruncate64(int file_descriptor, off64_t length);Service Program Name: QP0LLIB1
Default Public Authority: *USE
Threadsafe: Conditional; see Usage Notes.
The ftruncate64() function truncates the file indicated by the open file descriptor file_descriptor to the indicated length. file_descriptor must be a "regular file" that is open for writing. (A regular file is a stream file that can support positioning the file offset.) If the file size exceeds length, any extra data is discarded. If the file size is smaller than length, the file is extended and filled with binary zeros to the indicated length. (In the QSYS.LIB and independent ASP QSYS.LIB file systems, blanks are used instead of zeros to pad records after a member is extended.) The ftruncate64() function does not modify the current file offset for any open file descriptions associated with the file.
ftruncate64() is enabled for large files. It is capable of operating on files larger than 2GB minus 1 byte as long as the file has been opened by either of the following:
- Using the open64() function (see open64()--Open File (Large File Enabled)).
- Using the open() function (see open()--Open File) with the O_LARGEFILE flag set in the oflag parameter.
If ftruncate64() completes successfully, it marks the change time and modification times of the file. If ftruncate64() is not successful, the file is unchanged.
For additional information about parameters, authorities, error conditions, and examples, see ftruncate()--Truncate File.
Usage Notes
- For file systems that do support large files, this function will fail with
the [EFBIG] error if the length specified is greater than 2GB minus 1
byte and O_LARGEFILE is not set in the oflag.
- For file systems that do not support large files, this function will fail
with the [EINVAL] error if the length specified is greater than 2GB
minus 1 byte.
- QFileSvr.400 File System Differences
When connecting to a system at release V5R4M5 and earlier, QFileSvr.400 does not support ftruncate64() if the length specified is greater than 2GB minus 1 byte, [EFBIG] will be returned. Otherwise, the length is limited by the file system being accessed on the server.
- When you develop in C-based languages, the prototypes for the 64-bit APIs
are normally hidden. To use the ftruncate64() API and the
off64_t data type, you must compile the source with _LARGE_FILE_API
defined.
- All of the usage notes for ftruncate() apply to ftruncate64(). See Usage Notes in the ftruncate() API.
API introduced: V4R4