2013-09-05 18:55:36 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
var CFB = require('../cfb');
|
|
|
|
var args = process.argv.slice(2);
|
|
|
|
|
2013-09-20 22:43:02 +00:00
|
|
|
if(args.length === 0 || !require('fs').existsSync(args[0])) {
|
|
|
|
console.error("Usage: " + process.argv[1] + " <cfb_file>");
|
|
|
|
process.exit(1);
|
2013-09-05 18:55:36 +00:00
|
|
|
}
|
|
|
|
|
2013-09-20 22:43:02 +00:00
|
|
|
var cfb = CFB.read(args[0], {type:'file'});
|
|
|
|
if(args[1] === "-q") {
|
|
|
|
console.log(cfb);
|
|
|
|
return;
|
2013-09-05 18:55:36 +00:00
|
|
|
}
|
|
|
|
var fs = require('fs');
|
2013-09-20 22:43:02 +00:00
|
|
|
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]);
|
2013-09-05 18:55:36 +00:00
|
|
|
} else {
|
2013-09-20 22:43:02 +00:00
|
|
|
console.error("writing " + cfb.FullPaths[i]);
|
|
|
|
fs.writeFileSync(cfb.FullPaths[i], cfb.FileIndex[i].content);
|
2013-09-05 18:55:36 +00:00
|
|
|
}
|
|
|
|
}
|