Mono Class Library: Mono.Unix.UnixStream Overview | Members

Mono.Unix.UnixStream.ReadAtOffset Method

Reads a sequence of bytes from the current stream without advancing the position within the stream.

public int ReadAtOffset (byte[] buffer, int offset, int count, long fileOffset)

See Also

Mono.Unix.Native.Syscall.pread

Parameters

buffer
A byte array. When this method returns, the elements between offset and (offset + count) are replaced by the bytes read from the current source.
offset
A int that specifies the zero-based byte offset within buffer at which to begin storing the data read from the current stream.
count
A int that specifies the maximum number of bytes to be read from the current stream.
fileOffset
A long specifying the byte offset within the file to begin reading.

Returns

A int that specifies the number of bytes read into the buffer, or zero if the end of the stream has been reached before any data can be read.

Exceptions

TypeReason
ArgumentException(offset + count) is greater than the length of buffer.
ArgumentNullExceptionbuffer is null.
ArgumentOutOfRangeExceptionoffset or count is negative.
InvalidOperationException The file descriptor is associated with a file system and file type that do not allow regular read operations on it. [Mono.Unix.Native.Errno.EOPNOTSUPP]
NotSupportedException The stream does not support reading.
ObjectDisposedException The stream has been closed.
OverflowException The file descriptor is associated with a regular file, count is greater than 0, fileOffset is before the end-of-file, and fileOffset is greater than or equal to the offset maximum established for this file system. [Mono.Unix.Native.Errno.EOVERFLOW]
UnauthorizedAccessException The file descriptor is associated with a directory residing on a file system that does not allow regular read operations on directories (e.g.NFS). [Mono.Unix.Native.Errno.EISDIR]
System.IO.IOException

An I/O error occurred while reading from the file system. [Mono.Unix.Native.Errno.EIO]

-or-

The file descriptor is associated with a pipe, socket, or FIFO. [Mono.Unix.Native.Errno.ESPIPE]

Mono.Unix.UnixIOException The file was marked for non-blocking I/O, and no data were ready to be read. [Mono.Unix.Native.Errno.EAGAIN]

Remarks

Unlike System.IO.Stream.Read, this method does not modify System.IO.Stream.Position.

Note: Use the System.IO.Stream.CanRead property to determine whether the current instance supports reading.

Requirements

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