How to use the adm-zip/util.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 appcelerator / node-appc / lib / zip.js View on Github external
(function extractFile() {
			if (i < len) {
				try {
					const entry = zipEntries[i];

					if (visitor(entry, i, len) !== false) {
						if (entry.isDirectory) {
							Utils.makeDir(afs.resolvePath(dest, entry.entryName.toString()));
						} else {
							const content = entry.getData();
							if (!content) {
								// FIXME: This is clearly wrong, but not sure if downstream depends on this behavior!
								throw Utils.Errors.CANT_EXTRACT_FILE + '2'; // eslint-disable-line no-throw-literal
							}
							Utils.writeFileTo(
								afs.resolvePath(dest, entry.entryName.toString()),
								content,
								overwrite,
								(entry.header.attr && (entry.header.attr >>> 16) || defaultPerm) & 0o777
							);
						}
					}

					i++;
					setTimeout(extractFile, 0);
				} catch (ex) {
					finished(ex, i, len);
				}
			} else {
				// done!
				finished(null, i, len);