CBFSDirectStream Type

Syntax

CBFSDirectStream (declared in cbfsdirect.h)

Remarks

The CBFSDirectStream type is returned by some of the CBDirect class's methods. All stream types in CBFS Direct share a common API, documented below.

Properties

Length Gets or sets the length of the stream, in bytes.

int64 GetLength();
void SetLength(int64 length);
Position Gets or sets the current position within the stream.

int64 GetPosition();
void SetPosition(int64 position);

Methods

Close Closes the stream, releasing all resources currently allocated for it.

void Close();

This method is called automatically when a CBFSDirectStream object is deleted.

Flush Forces all data held by the stream's buffers to be written out to storage.

void Flush();
GetLastError If the previous operation failed, returns the associated error message, if any.

char* GetLastError();
GetLastErrorCode If the previous operation failed, returns a non-zero error code; otherwise returns zero.

int GetLastErrorCode();

This method will always return -1 after Close has been called.

Read Reads a sequence of bytes from the stream and advances the current position within the stream by the number of bytes read.

int Read(void* buffer, int count);

Buffer specifies the buffer to populate with data from the stream. Count specifies the number of bytes that should be read from the stream.

Returns the total number of bytes read into Buffer. This may be less than Count if that many bytes are not currently available, or may be 0 if the end of the stream has been reached.

Seek Sets the current position within the stream based on a particular point of origin.

int64 Seek(int64 offset, SeekOrigin origin);

enum SeekOrigin { soFromBeginning = 0, soFromCurrent = 1, soFromEnd = 2 };

Offset specifies the offset in the stream to seek to, relative to Origin. SeekOrigin is an enum declared alongside the CBFSDirectStream class as shown above.

Returns the new position within the stream.

Write Writes a sequence of bytes to the stream and advances the current position within the stream by the number of bytes written.

int Write(void* buffer, int count);

Buffer specifies the buffer with data to write to the stream. Count specifies the number of bytes that should be written to the stream.

Returns the total number of bytes written to the stream.

 
 
Copyright (c) 2021 Callback Technologies, Inc. - All rights reserved.
CBFS Direct 2020 C++ Edition - Version 20.0 [Build 7836]