How to use the adm-zip/util/index.js.writeFileTo 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
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;
github imlucas / lone / embed / admzip.js View on Github external
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) {
github imlucas / lone / embed / admzip.js View on Github external
writeZip: function(targetFileName, callback) {
                    if (arguments.length == 1) {
                        if (typeof targetFileName == "function") {
                            callback = targetFileName;
                            targetFileName = "";
                        }
                    }
                    if (!targetFileName && _filename) {
                        targetFileName = _filename;
                    }
                    if (!targetFileName) return;
                    var zipData = _zip.compressToBuffer();
                    if (zipData) {
                        Utils.writeFileTo(targetFileName, zipData, true);
                    }
                },
                toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {