Function READ

Syntax:

read file-descriptor desired-count => vector, effective-count

read file-descriptor vector &key(start 0) (end nil) => vector, effective-count

Arguments and values:

file-descriptor -- A non-negative integer.

desired-count -- A non-negative integer.

vector -- A vector with element-type (unsigned-byte 8).

start, end -- Bounding index designators of vector.

effective-count -- A non-negative integer.

Description:

The function read attempts to read up to desired-count bytes from the file descriptor file-descriptor.

In the first case, a freshly allocated vector is allocated and returned. The length vector is then the same as effective-count, except that if effective-count is 0, then vector is nil.

In the second case, the supplied vector is filled with the bytes read. The keyword argument start is the start index in vector where bytes are written. The default value is 0. The keyword argument end is the end index in vector where bytes are written. The default value is nil which means the end of the vector. Together, start and end define the number of desired bytes to read.

In both cases, two values are returned. The first value is the vector of bytes, whether supplied or allocated. The second value is the number of bytes actually read, which may be less than the desired number of bytes.

Errors:

If file-descriptor is not a valid file descriptor, or not open for reading, the condition invalid-file-descriptor is signaled.