The OpenD Programming Language

chunks

Iterates through a file a chunk at a time by using foreach.

chunks
(,
size_t size
)

Examples

void main()
{
    foreach (ubyte[] buffer; chunks(stdin, 4096))
    {
        ... use buffer ...
    }
}

The content of buffer is reused across calls. In the example above, buffer.length is 4096 for all iterations, except for the last one, in which case buffer.length may be less than 4096 (but always greater than zero).

In case of an I/O error, an StdioException is thrown.

Meta