(cb: (name: string, objs: FileSystem[]) => void)
| 5 | import _fs from '../../../src/core/node_fs'; |
| 6 | |
| 7 | export default function ZipFSFactory(cb: (name: string, objs: FileSystem[]) => void): void { |
| 8 | if (ZipFS.isAvailable()) { |
| 9 | XHRFSFactory((_, xhrfs) => { |
| 10 | if (xhrfs.length === 0) { |
| 11 | return cb('ZipFS', xhrfs); |
| 12 | } |
| 13 | |
| 14 | // Add three Zip FS variants for different zip files. |
| 15 | var zipFiles = ['0', '4', '9'], i: number, |
| 16 | rv: FileSystem[] = [], fs: typeof _fs = BrowserFS.BFSRequire('fs'); |
| 17 | // Leverage the XHRFS to download the fixtures for this FS. |
| 18 | BrowserFS.initialize(xhrfs[0]); |
| 19 | let countdown = zipFiles.length; |
| 20 | function fetchZip(zipFilename: string): void { |
| 21 | fs.readFile(zipFilename, (e, data?) => { |
| 22 | if (e) throw e; |
| 23 | if (countdown === 1) { |
| 24 | ZipFS.Create({ |
| 25 | zipData: data, |
| 26 | name: zipFilename |
| 27 | }, (e, fs?) => { |
| 28 | if (e) { |
| 29 | throw e; |
| 30 | } |
| 31 | countdown--; |
| 32 | rv.push(fs); |
| 33 | cb('ZipFS', rv); |
| 34 | }); |
| 35 | } else { |
| 36 | countdown--; |
| 37 | // Remove when constructor is deprecated. |
| 38 | rv.push(new ZipFS(data, zipFilename)); |
| 39 | } |
| 40 | }); |
| 41 | } |
| 42 | for (i = 0; i < zipFiles.length; i++) { |
| 43 | fetchZip(`/test/fixtures/zipfs/zipfs_fixtures_l${zipFiles[i]}.zip`); |
| 44 | } |
| 45 | }); |
| 46 | } else { |
| 47 | cb('ZipFS', []); |
| 48 | } |
| 49 | } |
nothing calls this directly
no test coverage detected