readCodeWithBuffer

Reads a file into a given buffer with a specified maximum length. If the file is bigger than the buffer, the buffer will be resized using the GC and updated through the ref argument.

char[]
readCodeWithBuffer
(
string file
,
scope return ref ubyte[] buffer
,
size_t maxLen = 1024 * 50
)

Parameters

file string

The filename of the file to read.

buffer ubyte[]

A GC allocated buffer that may be enlarged if it is too small.

maxLen size_t

The maxmimum amount of bytes to read from the file.

Return Value

Type: char[]

The contents of the file up to maxLen or EOF. The data is a slice of the buffer argument case to a char[].

Meta