The OpenD Programming Language

File.rawRead

Calls $(CSTDIO fread) for the file handle. The number of items to read and the size of each item is inferred from the size and type of the input array, respectively.

struct File
T[]
rawRead
(
T
)
(
T[] buffer
)

Return Value

Type: T[]

The slice of buffer containing the data that was actually read. This will be shorter than buffer if EOF was reached before the buffer could be filled. If the buffer is empty, it will be returned.

Throws

ErrnoException if the file is not opened or the call to fread fails.

rawRead always reads in binary mode on Windows.

Examples

static import std.file;

auto testFile = std.file.deleteme();
std.file.write(testFile, "\r\n\n\r\n");
scope(exit) std.file.remove(testFile);

auto f = File(testFile, "r");
auto buf = f.rawRead(new char[5]);
f.close();
assert(buf == "\r\n\n\r\n");

Meta