class
FileDataStream
Data stream for handling data from standard streams.
Public
Constructors
FileDataStream
Constructs a file stream.
- filePath
- Path of the file to open.
- accessMode
- Determines should the file be opened in read, write or read/write mode.
Methods
~FileDataStream
Open
Opens the file stream.
Must be called before any actions on the stream. Returns false if not successful.
IsFile
Checks whether the stream reads/writes from a file system.
Read
Read the requisite number of bytes from the stream, stopping at the end of the file.
Advances the read pointer.
- data
- Pre-allocated buffer to read the data into.
- byteCount
- Number of bytes to read.
Returns: Number of bytes actually read.
Write
Write the requisite number of bytes to the stream and advance the write pointer.
- data
- Buffer containing bytes to write.
- byteCount
- Number of bytes to write.
Returns: Number of bytes actually written.
Skip
Skip a defined number of bytes.
Returns the actual number of bytes skipped.
Seek
Repositions the read or write cursor to the specified byte.
Returns the actual byte the cursor has been placed at, in case end has been reached earlier
Tell
Returns the current cursor byte offset from beginning.
Eof
Returns true if the stream has reached the end.
Clone
Creates a copy of this stream.
- copyData
- If true the internal stream data will be copied as well, otherwise it will just reference the data from the original stream (in which case the caller must ensure the original stream outlives the clone). This is not relevant for file streams.
Flush
Flushes the stream, writing any buffer data to the destination.
Returns false if some error occurred and data was not written correctly. Does not need to be called if stream was just read from.
Close
Closes the stream.