How to use the adm-zip/zipFile.js function in adm-zip

To help you get started, we’ve selected a few adm-zip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imlucas / lone / embed / admzip.js View on Github external
module.exports = function(input) {
            var _zip = undefined, _filename = "";
            if (input && typeof input === "string") {
                if (fs.existsSync(input)) {
                    _filename = input;
                    _zip = new ZipFile(input, Utils.Constants.FILE);
                } else {
                    throw Utils.Errors.INVALID_FILENAME;
                }
            } else if (input && Buffer.isBuffer(input)) {
                _zip = new ZipFile(input, Utils.Constants.BUFFER);
            } else {
                _zip = new ZipFile(null, Utils.Constants.NONE);
            }
            function getEntry(entry) {
                if (entry && _zip) {
                    var item;
                    if (typeof entry === "string") item = _zip.getEntry(entry);
                    if (typeof entry === "object" && entry.entryName != undefined && entry.header != undefined) item = _zip.getEntry(entry.entryName);
                    if (item) {
                        return item;
                    }
                }
                return null;
            }
            return {
                readFile: function(entry) {
                    var item = getEntry(entry);
                    return item && item.getData() || null;
github imlucas / lone / embed / admzip.js View on Github external
module.exports = function(input) {
            var _zip = undefined, _filename = "";
            if (input && typeof input === "string") {
                if (fs.existsSync(input)) {
                    _filename = input;
                    _zip = new ZipFile(input, Utils.Constants.FILE);
                } else {
                    throw Utils.Errors.INVALID_FILENAME;
                }
            } else if (input && Buffer.isBuffer(input)) {
                _zip = new ZipFile(input, Utils.Constants.BUFFER);
            } else {
                _zip = new ZipFile(null, Utils.Constants.NONE);
            }
            function getEntry(entry) {
                if (entry && _zip) {
                    var item;
                    if (typeof entry === "string") item = _zip.getEntry(entry);
                    if (typeof entry === "object" && entry.entryName != undefined && entry.header != undefined) item = _zip.getEntry(entry.entryName);
                    if (item) {
                        return item;
                    }
github imlucas / lone / embed / admzip.js View on Github external
module.exports = function(input) {
            var _zip = undefined, _filename = "";
            if (input && typeof input === "string") {
                if (fs.existsSync(input)) {
                    _filename = input;
                    _zip = new ZipFile(input, Utils.Constants.FILE);
                } else {
                    throw Utils.Errors.INVALID_FILENAME;
                }
            } else if (input && Buffer.isBuffer(input)) {
                _zip = new ZipFile(input, Utils.Constants.BUFFER);
            } else {
                _zip = new ZipFile(null, Utils.Constants.NONE);
            }
            function getEntry(entry) {
                if (entry && _zip) {
                    var item;
                    if (typeof entry === "string") item = _zip.getEntry(entry);
                    if (typeof entry === "object" && entry.entryName != undefined && entry.header != undefined) item = _zip.getEntry(entry.entryName);
                    if (item) {
                        return item;
                    }
                }
                return null;
            }
            return {
                readFile: function(entry) {