BBSReadStream

public class BBSReadStream : InputStream, InitializationStateProvider

Overview

InputStream subclass for reading files that are in the secure store. This class is a subclass of the native InputStream class, for access to the BlackBerrySecurity secure file system.

Usage

This class supports the read and hasBytesAvailable member functions of InputStream. This class doesn’t support getBuffer, which will always return false. This class also doesn’t support scheduleInRunLoop nor removeFromRunLoop. Support for run loops isn’t required because the file data can be read immediately.

Notes on use of the read function

The read function in this class will work best when the supplied buffer is a multiple of 16 bytes in length. The maxLength parameter should reflect the size of the buffer, and not the amount of data remaining to be read from the file. To read a particular number of bytes, B, supply a buffer whose size is B rounded up to the next multiple of 16.

The return value of the read function must always be checked by the application. It mustn’t be assumed that a file has been completely read into a buffer, even if the buffer is large enough to accomodate the whole file.

  • Initializer that opens a file in the secure store, for reading.

    Call this initializer to open a file in the secure store for reading. Files in the secure store are encrypted on the device; this function provides access to decrypted data.

    Declaration

    Swift

    public init?(path filePath: String!) throws
  • Read from a file in the secure file system.

    The read function will work best when the supplied buffer is a multiple of 16 bytes in length. The maxLength parameter should reflect the size of the buffer, and not the amount of data remaining to be read from the file. To read a particular number of bytes, B, supply a buffer whose size is B rounded up to the next multiple of 16.

    The return value of the read function must always be checked by the application. It mustn’t be assumed that a file has been completely read into a buffer, even if the buffer is large enough to accomodate the whole file.

    Declaration

    Swift

    public override func read(_ buffer: UnsafeMutablePointer<UInt8>, maxLength len: Int) -> Int
  • Not supported, will always return false.

    Declaration

    Swift

    public override func getBuffer(_ buffer: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>, length len: UnsafeMutablePointer<Int>) -> Bool
  • Seek in an open file in the secure file system.

    Call this function to move the file pointer to a specific offset from the start of the stream.

    Declaration

    Swift

    public func seek(to fileOffset: UInt64) throws -> Bool

    Parameters

    fileOffset

    Required offset, expressed as a number of bytes from the start of the file. Zero means the start of the file.

    Return Value

    true if the file pointer was moved to the required offset, false otherwise.

  • The last error associated with the open stream.

    Declaration

    Swift

    public override var streamError: Error? { get }
  • Get the current the current status of the stream as a NSStreamStatus constant.

    Declaration

    Swift

    public override var streamStatus: Stream.Status { get }