diff --git a/LICENSE b/LICENSE index b74794c..0275eb7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2013 Niggler +Copyright 2013 SheetJS Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index a3c4ac0..fbda0e5 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ lint: jshint cfb.js init: - if [ ! -e test_files ]; then git clone https://github.com/Niggler/test_files; fi + if [ ! -e test_files ]; then git clone https://github.com/SheetJS/test_files; fi cd test_files; make clean: diff --git a/bin/cfb b/bin/cfb index 750888b..a84eee4 100755 --- a/bin/cfb +++ b/bin/cfb @@ -1,19 +1,26 @@ #!/usr/bin/env node var CFB = require('../cfb'); -var args = process.argv.slice(2); +var fs = require('fs'), program = require('commander'); +program + .version('0.7.0') + .usage('[options] ') + .option('-q, --quiet', 'print but do not extract') + .parse(process.argv); -if(args.length === 0 || !require('fs').existsSync(args[0])) { - console.error("Usage: " + process.argv[1] + " "); +if(program.args.length === 0 || !fs.existsSync(program.args[0])) { + console.error("Usage: " + process.argv[1] + " [-q] "); process.exit(1); } -var cfb = CFB.read(args[0], {type:'file'}); -if(args[1] === "-q") { - console.log(cfb); +var cfb = CFB.read(program.args[0], {type:'file'}); +if(program.quiet) { + console.log("Full Paths:") + console.log(cfb.FullPaths.map(function(x) { return " " + x; }).join("\n")); + console.log("Full Path Directory:") + console.log(cfb.FullPathDir); 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]); diff --git a/cfb.js b/cfb.js index 4ae1cea..380758c 100644 --- a/cfb.js +++ b/cfb.js @@ -322,14 +322,9 @@ function read_directory(idx) { minifat_size = o.size; } else if(o.size >= ms_cutoff_size) { o.storage = 'fat'; - try { - sector_list[o.start].name = o.name; - o.content = sector_list[o.start].data.slice(0,o.size); - } catch(e) { - o.start = o.start - 1; - sector_list[o.start].name = o.name; - o.content = sector_list[o.start].data.slice(0,o.size); - } + if(!sector_list[o.start] && dir_start > 0) o.start = (o.start + dir_start) % sectors.length; + sector_list[o.start].name = o.name; + o.content = sector_list[o.start].data.slice(0,o.size); prep_blob(o.content); } else { o.storage = 'minifat'; diff --git a/package.json b/package.json index ebec1b6..c1dca74 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,20 @@ { "name": "cfb", - "version": "0.6.0", - "author": "Niggler", + "version": "0.7.0", + "author": "SheetJS", "description": "Compound File Binary File Format extractor", "keywords": [ "cfb", "compression", "office" ], "bin": { "cfb": "./bin/cfb" }, "main": "./cfb", - "repository": { "type":"git", "url":"git://github.com/Niggler/js-cfb.git" }, + "repository": { "type":"git", "url":"git://github.com/SheetJS/js-cfb.git" }, "scripts": { "test": "make test" }, - "bugs": { "url": "https://github.com/Niggler/js-cfb/issues" }, + "dependencies": { + "commander":"" + }, + "bugs": { "url": "https://github.com/SheetJS/js-cfb/issues" }, "license": "Apache 2.0" }