SheetJS
8d10376fad
It is possible for multiple streams to have the same name (albeit with different paths), so: - `FileIndex` is an array of the streams - `FullPaths` is an array of the full paths - `FullPathDir` is a full path version of `Directory`
26 lines
646 B
JavaScript
Executable File
26 lines
646 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
var CFB = require('../cfb');
|
|
var args = process.argv.slice(2);
|
|
|
|
if(args.length === 0 || !require('fs').existsSync(args[0])) {
|
|
console.error("Usage: " + process.argv[1] + " <cfb_file>");
|
|
process.exit(1);
|
|
}
|
|
|
|
var cfb = CFB.read(args[0], {type:'file'});
|
|
if(args[1] === "-q") {
|
|
console.log(cfb);
|
|
return;
|
|
}
|
|
var fs = require('fs');
|
|
for(var i=0; i != cfb.FullPaths.length; ++i) {
|
|
if(cfb.FullPaths[i].slice(-1) === "/") {
|
|
console.error("mkdir " + cfb.FullPaths[i]);
|
|
fs.mkdirSync(cfb.FullPaths[i]);
|
|
} else {
|
|
console.error("writing " + cfb.FullPaths[i]);
|
|
fs.writeFileSync(cfb.FullPaths[i], cfb.FileIndex[i].content);
|
|
}
|
|
}
|