module watt.io.streams.fd

Streams that interact with *nix FDs.

Code Map

//! Streams that interact with *nix FDs.
module watt.io.streams.fd;


//! Size of the internal read/write buffer.
enum BufferSize;

//! An OutputStream in which the sink is a file.
class OutputFDStream : OutputStream
{
public:
	//! The file descriptor this stream wraps.
	fd: i32;


public:
	//! Construct a new OutputFDStream from a filename.
	this(filename: const(char)[]) { }
	//! Close the underlying file descriptor.
	fn close() { }
	//! Is this a valid stream?
	fn isOpen() bool { }
	//! Output c to the stream.
	fn put(c: dchar) { }
	//! Write s to the stream.
	fn write(s: scope (const(scope (char)[])) { }
	//! Ensure that all buffered output is written.
	fn flush() { }
}

//! An InputStream in which the source is a file.
class InputFDStream : InputStream
{
public:
	//! The underlying file descriptor.
	fd: i32;


public:
	//! Construct a new InputFDStream from a filename.
	this(filename: const(char)[]) { }
	//! Close the underlying file descriptor.
	fn close() { }
	//! Is this wrapping a valid file descriptor?
	fn isOpen() bool { }
	//! Read the first character from the file descriptor.
	fn get() dchar { }
	//! Read from the stream into buffer.
	fn read(buffer: u8[]) u8[] { }
	//! Has this descriptor reached EOF?
	fn eof() bool { }
}
enum BufferSize

Size of the internal read/write buffer.

class OutputFDStream : OutputStream

An OutputStream in which the sink is a file.

enum Max

Always reserve one slot for put.

fd: i32

The file descriptor this stream wraps.

this(filename: const(char)[])

Construct a new OutputFDStream from a filename.

fn close()

Close the underlying file descriptor.

fn isOpen() bool

Is this a valid stream?

fn put(c: dchar)

Output c to the stream.

fn write(s: scope (const(scope (char)[]))

Write s to the stream.

fn flush()

Ensure that all buffered output is written.

class InputFDStream : InputStream

An InputStream in which the source is a file.

fd: i32

The underlying file descriptor.

this(filename: const(char)[])

Construct a new InputFDStream from a filename.

fn close()

Close the underlying file descriptor.

fn isOpen() bool

Is this wrapping a valid file descriptor?

fn get() dchar

Read the first character from the file descriptor.

fn read(buffer: u8[]) u8[]

Read from the stream into buffer.

Return

A slice of the buffer actually used.

fn eof() bool

Has this descriptor reached EOF?