| 25 | } |
| 26 | |
| 27 | async readRange(startOffset?: number, endOffset?: number): Promise<string|null> { |
| 28 | if (!this.#lastBlob) { |
| 29 | Common.Console.Console.instance().error('Attempt to read a temp file that was never written'); |
| 30 | return ''; |
| 31 | } |
| 32 | const blob = typeof startOffset === 'number' || typeof endOffset === 'number' ? |
| 33 | this.#lastBlob.slice((startOffset as number), (endOffset as number)) : |
| 34 | this.#lastBlob; |
| 35 | |
| 36 | const reader = new FileReader(); |
| 37 | try { |
| 38 | await new Promise((resolve, reject) => { |
| 39 | reader.onloadend = resolve; |
| 40 | reader.onerror = reject; |
| 41 | reader.readAsText(blob); |
| 42 | }); |
| 43 | } catch (error) { |
| 44 | Common.Console.Console.instance().error('Failed to read from temp file: ' + error.message); |
| 45 | } |
| 46 | |
| 47 | return reader.result as string | null; |
| 48 | } |
| 49 | |
| 50 | async copyToOutputStream( |
| 51 | outputStream: Common.StringOutputStream.OutputStream, |