How to use the adm-zip/util/index.js.Errors 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
}
                        return data;
                    } else {
                        inflater.inflateAsync(function(result) {
                            result.copy(data, 0);
                            if (crc32OK(data)) {
                                if (callback) callback(data, Utils.Errors.BAD_CRC);
                            } else {
                                if (callback) callback(data);
                            }
                        });
                    }
                    break;
                  default:
                    if (async && callback) callback(new Buffer(0), Utils.Errors.UNKNOWN_METHOD);
                    return Utils.Errors.UNKNOWN_METHOD;
                }
            }
            function compress(async, callback) {
github imlucas / lone / embed / admzip.js View on Github external
function readMainHeader() {
                var i = inBuffer.length - Utils.Constants.ENDHDR, n = Math.max(0, i - 65535), endOffset = 0;
                for (i; i >= n; i--) {
                    if (inBuffer[i] != 80) continue;
                    if (inBuffer.readUInt32LE(i) == Utils.Constants.ENDSIG) {
                        endOffset = i;
                        break;
                    }
                }
                if (!endOffset) throw Utils.Errors.INVALID_FORMAT;
                mainHeader.loadFromBinary(inBuffer.slice(endOffset, endOffset + Utils.Constants.ENDHDR));
                if (mainHeader.commentLength) {
                    _comment = inBuffer.slice(endOffset + Utils.Constants.ENDHDR);
                }
                readEntries();
            }
            return {
github imlucas / lone / embed / admzip.js View on Github external
loadFromBinary: function(data) {
                    if (data.length != Constants.ENDHDR || data.readUInt32LE(0) != Constants.ENDSIG) throw Utils.Errors.INVALID_END;
                    _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
                    _totalEntries = data.readUInt16LE(Constants.ENDTOT);
                    _size = data.readUInt32LE(Constants.ENDSIZ);
                    _offset = data.readUInt32LE(Constants.ENDOFF);
                    _commentLength = data.readUInt16LE(Constants.ENDCOM);
                },
                toBinary: function() {
github imlucas / lone / embed / admzip.js View on Github external
loadDataHeaderFromBinary: function(input) {
                    var data = input.slice(_offset, _offset + Constants.LOCHDR);
                    if (data.readUInt32LE(0) != Constants.LOCSIG) {
                        throw Utils.Errors.INVALID_LOC;
                    }
                    _dataHeader = {
                        version: data.readUInt16LE(Constants.LOCVER),
                        flags: data.readUInt16LE(Constants.LOCFLG),
                        method: data.readUInt16LE(Constants.LOCHOW),
                        time: data.readUInt32LE(Constants.LOCTIM),
                        crc: data.readUInt32LE(Constants.LOCCRC),
                        compressedSize: data.readUInt32LE(Constants.LOCSIZ),
                        size: data.readUInt32LE(Constants.LOCLEN),
                        fnameLen: data.readUInt16LE(Constants.LOCNAM),
                        extraLen: data.readUInt16LE(Constants.LOCEXT)
                    };
                },
                loadFromBinary: function(data) {
github imlucas / lone / embed / admzip.js View on Github external
target = pth.resolve(target, "..");
                        var children = _zip.getEntryChildren(item);
                        children.forEach(function(child) {
                            if (child.isDirectory) return;
                            var content = child.getData();
                            if (!content) {
                                throw Utils.Errors.CANT_EXTRACT_FILE;
                            }
                            Utils.writeFileTo(pth.resolve(targetPath, maintainEntryPath ? child.entryName : child.entryName.substr(item.entryName.length)), content, overwrite);
                        });
                        return true;
                    }
                    var content = item.getData();
                    if (!content) throw Utils.Errors.CANT_EXTRACT_FILE;
                    if (fs.existsSync(targetPath) && !overwrite) {
                        throw Utils.Errors.CANT_OVERRIDE;
                    }
                    Utils.writeFileTo(target, content, overwrite);
                    return true;
                },
                extractAllTo: function(targetPath, overwrite) {