Write v0.1.0

Source
Writes bytes to a file descriptor.

Package: Linux

Signature

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

Parameters

NameTypeDescription
fdint32File descriptor to write.
buffer*const opaqueSource containing at least count bytes.
countuintNumber of bytes requested.

Returns

int64 — bytes written on success, or a negative errno result on failure.

Description

Write is a thin wrapper around Linux write(2). A successful call may write fewer than count bytes. Code that must emit the complete buffer should advance the pointer and repeat until all bytes are written or an error occurs.

Example

import Linux::{ IsError, StdOut, Write };

func Main() -> int {
    let message = "hello\n";
    let result = Write(StdOut, message.data, message.length);
    if IsError(result) || result != message.length as int64 {
        return 1;
    }
    return 0;
}

See also

  • Read — read bytes from a descriptor
  • Close — close a descriptor