2014-05-16 00:33:34 +00:00
|
|
|
function readSync(data, opts) {
|
2014-01-28 16:38:02 +00:00
|
|
|
var zip, d = data;
|
2014-05-16 00:33:34 +00:00
|
|
|
var o = opts||{};
|
|
|
|
if(!o.type) o.type = (typeof Buffer !== 'undefined' && data instanceof Buffer) ? "buffer" : "base64";
|
|
|
|
switch(o.type) {
|
2014-01-28 16:38:02 +00:00
|
|
|
case "base64": zip = new jszip(d, { base64:true }); break;
|
|
|
|
case "binary": zip = new jszip(d, { base64:false }); break;
|
2014-05-16 00:33:34 +00:00
|
|
|
case "buffer": zip = new jszip(d); break;
|
|
|
|
case "file": zip=new jszip(d=_fs.readFileSync(data)); break;
|
|
|
|
default: throw new Error("Unrecognized type " + o.type);
|
2014-01-28 16:38:02 +00:00
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
return parse_zip(zip, o);
|
2014-01-28 16:38:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
function readFileSync(data, opts) {
|
|
|
|
var o = opts||{}; o.type = 'file';
|
2014-01-28 16:38:02 +00:00
|
|
|
return readSync(data, o);
|
|
|
|
}
|
|
|
|
|