libperun

Class std.posix.Posix

Synopsis

public static class Posix

Interface to POSIX-specific functions for Perun.

Fields

public static final int O_RDWR

File open flags.

public static final int O_RDONLY

No description given

public static final int O_WRONLY

No description given

public static final int O_APPEND

No description given

public static final int O_CREAT

No description given

public static final int O_EXCL

No description given

public static final int O_NOCTTY

No description given

public static final int O_NONBLOCK

No description given

public static final int O_TRUNC

No description given

public static final int SEEK_SET

Seek whence values.

public static final int SEEK_CUR

No description given

public static final int SEEK_END

No description given

Constructors

Methods

public static int open(String filename,int flags,int mode);

Open a file and return the file descriptor.

Arguments
filenamePath to the file to open.
flagsBitwise-OR of file open flags (O_*). Must include one of O_RDONLY, O_WRONLY or O_RDWR.
modeFile access mode to use if a new file is being created.
Returns

The file descriptor returned by open().

Throws
std.posix.PosixErrorIf open() returns an error.
public static int write(int fd,int offset,byte_t[] buffer);

Write to a file, given a file descriptor.

Arguments
fdThe file descriptor.
offsetOffset into the buffer to begin writing from.
bufferThe array of bytes to be written to the file.
Returns

The number of bytes actually written.

Throws
std.posix.PosixErrorIf write() returns an error.
public static int read(int fd,byte_t[] buffer);

Read from a file, given a file descriptor.

Arguments
fdThe file descriptor.
bufferThe array of bytes into which data will be read.
Returns

The number of bytes actually read.

Throws
std.posix.PosixErrorIf read() returns an error.
public static void close(int fd);

Close the given file descriptor.

public static bool isatty(int fd);

Returns true if the specified file descriptor refers to a terminal.

public static long lseek(int fd,long offset,int whence);

Seek a file.

Arguments
fdThe file descriptor.
offsetThe offset from whence to seek to.
whenceOne of the SEEK_* constants.
Returns

The new offset.

Throws
std.posix.PosixErrorIf lseek() returns an error.