CBFSVaultStream Type

Syntax

CBFSVaultStream (declared in CBFSVaultStreams.h)

Remarks

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

This type provides a custom streaming API with full read, write, and seek functionality. To interact with a stream via conventional Objective-C streaming APIs, use the inputStream and outputStream methods to obtain an NSInputStream or NSOutputStream object.
This type provides a custom streaming API with full read, write, and seek functionality. To interact with a stream via conventional Swift streaming APIs, use the inputStream and outputStream methods to obtain an InputStream or OutputStream object.

Properties

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

@property (nonatomic,readwrite,assign,getter=length,setter=setLength:) long long length;
- (long long)length;
- (void)setLength:(long long)newLength;
position Gets or sets the current position within the stream.

@property (nonatomic,readwrite,assign,getter=position,setter=setPosition:) long long position;
- (long long)position;
- (void)setPosition:(long long)newPosition;

Methods

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

- (void)close;

Closing a CBFSVaultStream instance invalidates any stream objects that have been created using its inputStream and outputStream methods. This method is called automatically when a CBFSVaultStream 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 CBFSVaultStream instance.

- (NSInputStream*)inputStream;

The NSInputStream instance is returned in an "opened" state initially; when it is closed, the CBFSVaultStream instance that returned it is also closed (which, as close describes, causes all other standard stream objects tied to that CBFSVaultStream 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 CBFSVaultStream instance.

- (NSOutputStream*)outputStream;

The NSOutputStream instance is returned in an "opened" state initially; when it is closed, the CBFSVaultStream instance that returned it is also closed (which, as close describes, causes all other standard stream objects tied to that CBFSVaultStream 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 CBFSVaultStreams.h):

  • STREAM_SEEK_FROM_BEGIN (0)
  • STREAM_SEEK_FROM_CURRENT (1)
  • STREAM_SEEK_FROM_END (2)

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 {
get {...}
set {...}
}
position Gets or sets the current position within the stream.

public var position: Int64 {
get {...}
set {...}
}

Methods

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

public func close() -> Void

Closing a CBFSVaultStream instance invalidates any stream objects that have been created using its inputStream and outputStream methods. This method is called automatically when a CBFSVaultStream 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 CBFSVaultStream instance.

public func inputStream() -> InputStream

The InputStream instance is returned in an "opened" state initially; when it is closed, the CBFSVaultStream instance that returned it is also closed (which, as close describes, causes all other standard stream objects tied to that CBFSVaultStream 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 CBFSVaultStream instance.

public func outputStream() -> OutputStream

The OutputStream instance is returned in an "opened" state initially; when it is closed, the CBFSVaultStream instance that returned it is also closed (which, as close describes, causes all other standard stream objects tied to that CBFSVaultStream 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 CBFSVaultStreams.h):

  • STREAM_SEEK_FROM_BEGIN (0)
  • STREAM_SEEK_FROM_CURRENT (1)
  • STREAM_SEEK_FROM_END (2)

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.

Copyright (c) 2021 Callback Technologies, Inc. - All rights reserved.
CBFS Vault 2020 iOS Edition - Version 20.0 [Build 7986]