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
Open a file and return the file descriptor.
Arguments
filename | Path to the file to open. |
---|---|
flags | Bitwise-OR of file open flags (O_*). Must include one of O_RDONLY, O_WRONLY or O_RDWR. |
mode | File access mode to use if a new file is being created. |
Returns
The file descriptor returned by open()
.
Throws
std.posix.PosixError | If open() returns an error. |
---|
public static int write(int fd,int offset,byte_t[] buffer);
Write to a file, given a file descriptor.
Arguments
fd | The file descriptor. |
---|---|
offset | Offset into the buffer to begin writing from. |
buffer | The array of bytes to be written to the file. |
Returns
The number of bytes actually written.
Throws
std.posix.PosixError | If write() returns an error. |
---|
public static int read(int fd,byte_t[] buffer);
Read from a file, given a file descriptor.
Arguments
fd | The file descriptor. |
---|---|
buffer | The array of bytes into which data will be read. |
Returns
The number of bytes actually read.
Throws
std.posix.PosixError | If 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
fd | The file descriptor. |
---|---|
offset | The offset from whence to seek to. |
whence | One of the SEEK_* constants. |
Returns
The new offset.
Throws
std.posix.PosixError | If lseek() returns an error. |
---|