js-cfb/bin/cfb
SheetJS 8d10376fad version bump 0.3.0: name collision resolution
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`
2013-09-20 23:13:19 -07:00

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);
}
}