Mono.Unix.Native.Syscall.ftruncate Method
Truncate or extend a file to length

Syntax

public static int ftruncate (int fd, long length)

See Also

Syscall.open

Parameters

fd
Documentation for this section has not yet been entered.
length
Documentation for this section has not yet been entered.

Returns

On success, zero is returned. On error, -1 is returned and Stdlib.GetLastError returns the translated error.

Usage

The ftruncate() system call succeeds unless:

Error Details
Errno.EBADF

The fd argument is not a valid descriptor.

Errno.EINVAL

The fd argument references a socket, not a file.

Errno.EINVAL

The fd descriptor is not open for writing.

Remarks

The truncate() system call causes the file named by path or referenced by fd to be truncated or extended to length bytes in size. If the file was larger than this size, the extra data is lost. If the file was smaller than this size, it will be extended as if by writing bytes with the value zero. With ftruncate(), the file must be open for writing.

Requirements

Namespace: Mono.Unix.Native
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0