1 |
|
---|
2 | Mad.BinaryStrings.SubStream = function(stream, offset, length) {
|
---|
3 | this.offset = 0;
|
---|
4 | this.start = offset;
|
---|
5 | this.parentStream = stream;
|
---|
6 | this.length = length;
|
---|
7 | }
|
---|
8 |
|
---|
9 | Mad.BinaryStrings.SubStream.prototype = new Mad.BinaryStrings.ByteStream;
|
---|
10 |
|
---|
11 | Mad.BinaryStrings.SubStream.prototype.substream = function (offset, length) {
|
---|
12 | return new Mad.BinaryStrings.SubStream(this.parentStream, this.start + offset, length);
|
---|
13 | }
|
---|
14 |
|
---|
15 |
|
---|
16 | Mad.BinaryStrings.SubStream.prototype.absoluteAvailable = function(n) {
|
---|
17 | return this.parentStream.absoluteAvailable(this.start + n);
|
---|
18 | }
|
---|
19 |
|
---|
20 | Mad.BinaryStrings.SubStream.prototype.seek = function(n) {
|
---|
21 | this.offset += n;
|
---|
22 | }
|
---|
23 |
|
---|
24 | Mad.BinaryStrings.SubStream.prototype.read = function(n) {
|
---|
25 | var result = this.peek(n);
|
---|
26 |
|
---|
27 | this.seek(n);
|
---|
28 |
|
---|
29 | return result;
|
---|
30 | }
|
---|
31 |
|
---|
32 | Mad.BinaryStrings.SubStream.prototype.peek = function(n) {
|
---|
33 | return this.get(this.offset, n);
|
---|
34 | }
|
---|
35 |
|
---|
36 | Mad.BinaryStrings.SubStream.prototype.get = function(offset, length) {
|
---|
37 | return this.parentStream.get(this.start + offset, length);
|
---|
38 | }
|
---|
39 |
|
---|
40 | Mad.BinaryStrings.SubStream.prototype.slice = function(start, end) {
|
---|
41 | return this.parentStream.get(this.start + start, end - start);
|
---|
42 | }
|
---|
43 |
|
---|
44 | Mad.BinaryStrings.SubStream.prototype.requestAbsolute = function(n, callback) {
|
---|
45 | this.parentStream.requestAbsolute(this.start + n)
|
---|
46 | }
|
---|
47 |
|
---|
48 | Mad.BinaryStrings.SubStream.prototype.request = function(n, callback) {
|
---|
49 | this.parentStream.requestAbsolute(this.start + this.offset + n)
|
---|
50 | }
|
---|