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||{};
|
2014-07-28 13:22:32 +00:00
|
|
|
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
|
2014-05-16 00:33:34 +00:00
|
|
|
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) {
|
2015-03-05 17:18:36 +00:00
|
|
|
var o = opts||{}; o.type = 'file'
|
|
|
|
var wb = readSync(data, o);
|
|
|
|
wb.FILENAME = data;
|
|
|
|
return wb;
|
2014-01-28 16:38:02 +00:00
|
|
|
}
|
|
|
|
|