It is a convenience class for wrapping a File in a BufferedStream. A buffered stream must be closed explicitly to ensure the final buffer content is written to the file.
A buffered stream must be closed explicitly to ensure the final buffer content is written to the source stream. The source stream position is changed according to the block size so reading or writing to the BufferedStream may not change the source stream position by the same amount.
UTF Byte-Order-Mark (BOM) signatures can be read and deduced or written. Note that an EndianStream should not be used as the source of another FilterStream since a FilterStream call the source with byte-oriented read/write requests and the EndianStream will not perform any byte swapping. The EndianStream reads and writes binary data (non-getc functions) in a one-to-one manner with the source stream so the source stream's position and state will be kept in sync with the EndianStream if only non-getc functions are called.
If there is no BOM or if bytes beyond the BOM are read then the bytes read are pushed back onto the ungetc buffer or ungetcw buffer. Pass ungetCharSize == 2 to use ungetcw instead of ungetc when no BOM is present.
The method implementations forward read/write/seek calls to the source stream. A FilterStream can change the position of the source stream arbitrarily and may not keep the source stream state in sync with the FilterStream, even upon flushing and closing the FilterStream. It is recommended to not make any assumptions about the state of the source position and read/write state after a FilterStream has acted upon it. Specifc subclasses of FilterStream should document how they modify the source stream and if any invariants hold true between the source and filter.
well.
Defaults to true.
It could be used to section a large file into a set of smaller files, such as with tar archives. Reading and writing a SliceStream does not modify the position of the source stream if it is seekable.
The high part of the slice is dependent upon the end of the source stream, so that if you write beyond the end it resizes the stream normally.
Stream's byte order is the format native to the computer.
The type Buffer must support the length property, opIndex and opSlice. Compile in release mode when directly instantiating a TArrayStream to avoid link errors.
This does not require actually reading past the end, as with stdio. For non-seekable streams this might only return true after attempting to read past the end.
This is the only method that will handle ungetc properly. getcw's format is implementation-specific. If EOF is reached then getc returns char.init and getcw returns wchar.init.
This is the only method that will handle ungetc properly. getcw's format is implementation-specific. If EOF is reached then getc returns char.init and getcw returns wchar.init.
The string passed in line may be reused between calls to the delegate. Line numbering starts at 1. Breaking out of the foreach will leave the stream position at the beginning of the next line to be read. For example, to echo a file line-by-line with line numbers run:
Throws a ReadException if it is not correct.
An argument of type string is interpreted as a format string. All other arguments must be pointer types. If a format string is not present a default will be supplied computed from the base type of the pointer type. An argument of type string* is filled (possibly with appending characters) and a slice of the result is assigned back into the argument. For example the following readf statements are equivalent:
The terminators are not included. The wchar version is identical. The optional buffer parameter is filled (reallocating it if necessary) and a slice of the result is returned.
The terminators are not included. The wchar version is identical. The optional buffer parameter is filled (reallocating it if necessary) and a slice of the result is returned.
throwing ReadException if there was a problem.
The file format is implementation-specific and should not be used except as opposite actions to write.
They will be returned in first-in last-out order from getc/getcw. Only has effect on further calls to getc() and getcw().
They will be returned in first-in last-out order from getc/getcw. Only has effect on further calls to getc() and getcw().
An argument of type string is interpreted as a format string. All other arguments must be pointer types. If a format string is not present a default will be supplied computed from the base type of the pointer type. An argument of type string* is filled (possibly with appending characters) and a slice of the result is assigned back into the argument. For example the following readf statements are equivalent:
Throws WriteException on error.
The format is implementation-specific. Throws WriteException on error.
Throws WriteException if it could not be fully written.
The format is implementation-specific. Throws WriteException if it could not be fully written.