Read v0.1.0

Source
Reads bytes from a file descriptor.

Package: Bsd

Signature

func Read(fd: int32, buffer: *opaque, count: uint) -> int64;

Parameters

NameTypeDescription
fdint32File descriptor to read.
buffer*opaqueWritable destination for up to count bytes.
countuintMaximum number of bytes to read.

Returns

int64 - bytes read on success, 0 at end of file, or a negative errno value on failure. A successful call may return fewer than count bytes.

Example

import Bsd::{ Read, StdIn };

func Main() -> int {
    var buffer: char8[256];
    let result = Read(StdIn, buffer.data, 256u);
    if result == 0i64 {
        // End of file.
    }
    return 0;
}

See also

  • Bsd — the package overview
  • Write - write bytes