Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 1x 1x 1x 1x 2x 2x 1x 2x 2x 1x 1x 2x 2x 1x 1x 1x | import { changeExt, getType, copyFileAsync, extractGz } from "./utils";
import { loadXml } from "./xml";
import path from "path";
export const INVALID_FILE = new Error("File type cannot be recognized");
export class Reader {
file: string;
gzfile: string;
xmlJs: any;
constructor(file: string) {
this.file = file;
this.gzfile = changeExt(this.file, ".gz");
}
async load() {
// TODO: Make Parser Smart, when the project folder is given find the project file.
var fileType = await getType(this.file);
if (fileType == undefined) throw INVALID_FILE;
Iif (fileType.mime != "application/xml" && fileType.mime != "application/gzip") throw INVALID_FILE;
// If file is not already extracted
if (IfileType.mime != "application/xml") {
await copyFileAsync(this.file, this.gzfile);
await extractGz(this.gzfile, this.file);
}
this.xmlJs = await loadXml(this.file);
return this.xmlJs;
}
} |