new AxSubStream(mainStream, lengthnon-null, offsetnon-null, writeBeyondLengthnon-null)
Creates a new substream of an existing stream
The substream is a virtual stream, which uses an isolated portion of contents of another stream
Parameters:
Name | Type | Description |
---|---|---|
mainStream |
AxStream | The main stream for the substream |
length |
Integer | The length of the substream. If omitted or -1, the whole remaining length between the given offset and the size of the main stream is assumed. |
offset |
Integer | The offset location in the main stream, at which the substream starts. If omitted or -1, the current position of the main stream is assumed. |
writeBeyondLength |
Boolean | Denotes whether to allow for writing data beyond the specified length of the substream. If omitted, true is assumed. |
- Source:
Methods
ReadData(data, size) → {Integer}
Reads data from the sub stream and returns the number of bytes which were successfully read.
The position of the original stream is not changed
Parameters:
Name | Type | Description |
---|---|---|
data |
ArrayBuffer | An array buffer of the appropriate size, into which the read data will be stored |
size |
Integer | Number of bytes to read |
- Source:
Returns:
The number of bytes which were successfully read
- Type
- Integer
WriteData(data, size) → {Integer}
Writes data to the sub stream and returns the number of bytes which were successfully written
If writing at a position before the end of the stream, depending on the stream's write mode, new data can either overwite bytes ahead of the position or be inserted - pushing the existing data forward.
The position of the original stream is not changed
Parameters:
Name | Type | Description |
---|---|---|
data |
ArrayBuffer | An array buffer which holds the data to be written |
size |
Integer | Number of bytes to write |
- Source:
Returns:
The number of bytes which were successfully written
- Type
- Integer