How to use the adm-zip/util/index.js.findFiles 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
addLocalFolder: function(localPath, zipPath) {
                    if (zipPath) {
                        zipPath = zipPath.split("\\").join("/");
                        if (zipPath.charAt(zipPath.length - 1) != "/") {
                            zipPath += "/";
                        }
                    } else {
                        zipPath = "";
                    }
                    localPath = localPath.split("\\").join("/");
                    if (localPath.charAt(localPath.length - 1) != "/") localPath += "/";
                    if (fs.existsSync(localPath)) {
                        var items = Utils.findFiles(localPath), self = this;
                        if (items.length) {
                            items.forEach(function(path) {
                                var p = path.split("\\").join("/").replace(localPath, "");
                                if (p.charAt(p.length - 1) !== "/") {
                                    self.addFile(zipPath + p, fs.readFileSync(path), "", 0);
                                } else {
                                    self.addFile(zipPath + p, new Buffer(0), "", 0);
                                }
                            });
                        }
                    } else {
                        throw Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath);
                    }
                },
                addFile: function(entryName, content, comment, attr) {