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:

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

  1. 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.

  2. 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.

  3. QFileSvr.400 File System Differences

    Although QFileSvr.400 does not support large files, it will return [EFBIG] if the length specified is greater than 2GB minus 1 byte.

  4. 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.

  5. All of the usage notes for ftruncate() apply to ftruncate64(). See Usage Notes in the ftruncate() API.


API introduced: V4R4
Top | UNIX-Type APIs | APIs by category