Mono Class Library: Mono.Unix.Native.Stdlib Overview | Members

Mono.Unix.Native.Stdlib.fseek Method

Set file position for a FILE stream. [Edit]

[System.CLSCompliant(false)]
public static int fseek (IntPtr stream, long offset, SeekFlags origin)

Parameters

stream
FILE stream to seek. [Edit]
offset
Number of bytes to add to the the file offset specified by whence. [Edit]
origin
File offset to add offset to. [Edit]

Returns

Returns 0 if successful; otherwise -1 is returned and Stdlib.GetLastError indicates the error.

Usage

The following errors are specified:

ErrorDetails
Errno.EBADFThe stream argument is not not a seekable stream
Errno.EINVALThe whence argument is invalid or the resulting file-position indicator would be set to a negative value.
Errno.EOVERFLOWThe resulting file offset would be a value which cannot be represented correctly in an object of type stem.Int64 for Stdlib.fseek() and Stdlib.ftell().
Errno.ESPIPEThe file descriptor underlying stream is associated with a pipe or FIFO or file-position indicator value is unspecified (see Stdlib.ungetc(3)).

fseek may also fail for any of the error specified for the routines Stdlib.fflush(3), Syscall.fstat(2), Syscall.lseek(2), and Stdlib.malloc(3)

[Edit]

Remarks

The fseek() function sets the file position indicator for the stream pointed to by stream. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to SeekFlags.SEEK_SET, SeekFlags.SEEK_CUR, or SeekFlags.SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively. A successful call to the fseek() function clears the end-of-file indicator for the stream and undoes any effects of the Stdlib.ungetc(3) and Stdlib.ungetwc(3) functions on the same stream. [Edit]

Requirements

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