(file, chunksize = (1024 * 1024), callback = default_callback)
| 31 | let tempFiles |
| 32 | |
| 33 | var ChunkReader = function ChunkReader(file, chunksize = (1024 * 1024), callback = default_callback) { |
| 34 | |
| 35 | if(file == undefined) { |
| 36 | throw new Error('Invalid argument for file parameter.'); |
| 37 | } |
| 38 | |
| 39 | if(readers == undefined) { readers = []; } //Free list |
| 40 | |
| 41 | |
| 42 | this.chunksize = chunksize; //Read a kilobyte at a time |
| 43 | this.filesize = file.size; |
| 44 | this.offset = 0; |
| 45 | |
| 46 | //Start reading the chunks |
| 47 | while(this.offset + this.chunksize <= this.filesize) { |
| 48 | |
| 49 | this.blob = file.slice(this.offset, this.offset+this.chunksize); |
| 50 | |
| 51 | readers[readers.length] = new FileReader(); |
| 52 | readers[readers.length-1].onloadend = function(e) { |
| 53 | callback(e.target.result); |
| 54 | }; |
| 55 | readers[readers.length-1].readAsArrayBuffer(this.blob); |
| 56 | // console.log('Sending chunk from 0x'+this.offset.toString(16)); |
| 57 | this.offset+=this.chunksize; |
| 58 | } |
| 59 | |
| 60 | for(obj = 0; obj < readers.length; obj++) { |
| 61 | readers[obj] = undefined; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | // Clean up readers |
| 66 | readers = undefined |
| 67 | // free("readers"); |
| 68 | }; |
| 69 | |
| 70 | export function MachoParser(file, callback) { |
| 71 |
nothing calls this directly
no test coverage detected