CBFSStorageStream Type
Syntax
CBFSStorageStream (declared in cbfsstorage.h for C++, and in CBFSStorageStreams.h for Objective-C/Swift)
Remarks
The CBFSStorageStream type is returned by some of the CBDrive class's methods. All stream types in CBFS Storage share a common API, documented below.
Properties | |
Length |
Gets or sets the length of the stream, in bytes.
int64 GetLength(); |
Position |
Gets or sets the current position within the stream.
int64 GetPosition(); |
Methods | |
Close |
Closes the stream, releasing all resources currently allocated for it.
void Close(); This method is called automatically when a CBFSStorageStream 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); Offset specifies the offset in the stream to seek to, relative to Origin. SeekOrigin is an enum declared alongside the CBFSStorageStream 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. |
Properties | |
length |
Gets or sets the length of the stream, in bytes.
@property (nonatomic,readwrite,assign,getter=length,setter=setLength:) long long length; |
position |
Gets or sets the current position within the stream.
@property (nonatomic,readwrite,assign,getter=position,setter=setPosition:) long long position; |
Methods | |
close |
Closes the stream, releasing all resources currently allocated for it.
- (void)close; Closing a CBFSStorageStream instance invalidates any stream objects that have been created using its inputStream and outputStream methods. This method is called automatically when a CBFSStorageStream object is released. |
flush |
Forces all data held by the stream's buffers to be written out to storage.
- (void)flush; |
inputStream |
Returns a standard Objective-C NSInputStream tied to the current CBFSStorageStream instance.
- (NSInputStream*)inputStream; The NSInputStream instance is returned in an "opened" state initially; when it is closed, the CBFSStorageStream instance that returned it is also closed (which, as close describes, causes all other standard stream objects tied to that CBFSStorageStream instance to be invalidated). |
lastError |
If the previous operation failed, returns the associated error message, if any.
- (NSString*)lastError; |
lastErrorCode |
If the previous operation failed, returns a non-zero error code; otherwise returns zero.
- (int)lastErrorCode; This method will always return -1 after close has been called. |
outputStream |
Returns a standard Objective-C NSOutputStream tied to the current CBFSStorageStream instance.
- (NSOutputStream*)outputStream; The NSOutputStream instance is returned in an "opened" state initially; when it is closed, the CBFSStorageStream instance that returned it is also closed (which, as close describes, causes all other standard stream objects tied to that CBFSStorageStream instance to be invalidated). |
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 is reached. Returns -1 if an error occurs or the stream is closed. |
seek |
Sets the current position within the stream based on a particular point of origin.
- (long long)seek:(long long)offset :(int)origin; offset specifies the offset in the stream to seek to, relative to origin, which must be one of the following (declared at the top of CBFSStorageStreams.h):
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, or -1 if an error occurs or the stream is closed. |
Properties | |
length |
Gets or sets the length of the stream, in bytes.
public var length: Int64 { |
position |
Gets or sets the current position within the stream.
public var position: Int64 { |
Methods | |
close |
Closes the stream, releasing all resources currently allocated for it.
public func close() -> Void Closing a CBFSStorageStream instance invalidates any stream objects that have been created using its inputStream and outputStream methods. This method is called automatically when a CBFSStorageStream object is released. |
flush |
Forces all data held by the stream's buffers to be written out to storage.
public func flush() -> Void |
inputStream |
Returns a standard Swift InputStream tied to the current CBFSStorageStream instance.
public func inputStream() -> InputStream The InputStream instance is returned in an "opened" state initially; when it is closed, the CBFSStorageStream instance that returned it is also closed (which, as close describes, causes all other standard stream objects tied to that CBFSStorageStream instance to be invalidated). |
lastError |
If the previous operation failed, returns the associated error message, if any.
public func lastError() -> String |
lastErrorCode |
If the previous operation failed, returns a non-zero error code; otherwise returns zero.
public func lastErrorCode() -> Int32 This method will always return -1 after close has been called. |
outputStream |
Returns a standard Swift OutputStream tied to the current CBFSStorageStream instance.
public func outputStream() -> OutputStream The OutputStream instance is returned in an "opened" state initially; when it is closed, the CBFSStorageStream instance that returned it is also closed (which, as close describes, causes all other standard stream objects tied to that CBFSStorageStream instance to be invalidated). |
read |
Reads a sequence of bytes from the stream and advances the current position within the stream by the number of bytes read.
public func read(_ buffer: UnsafeRawPointer, _ count: Int32) -> Int32 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 is reached. Returns -1 if an error occurs or the stream is closed. |
seek |
Sets the current position within the stream based on a particular point of origin.
public func seek(_ offset: Int64, _ origin: Int32) -> Int64 offset specifies the offset in the stream to seek to, relative to origin, which must be one of the following (declared at the top of CBFSStorageStreams.h):
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.
public func write(_ buffer: UnsafeRawPointer, _ count: Int32) -> Int32 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, or -1 if an error occurs or the stream is closed. |