injectEntry static method

Future<void> injectEntry(
  1. File zipFile,
  2. ByteEntry entry
)

Implementation

static Future<void> injectEntry(File zipFile, ByteEntry entry) {
  Directory tmp = Directory("${zipFile.path}.tmp");
  File entryFile = File(tmp.path + Platform.pathSeparator + entry.path);
  return ZipFile.extractToDirectory(zipFile: zipFile, destinationDir: tmp)
      .then((_) => entryFile.writeAsBytes(entry.data.buffer.asUint8List()))
      .then((_) =>
          ZipFile.createFromDirectory(sourceDir: tmp, zipFile: zipFile))
      .then((_) => tmp.delete(recursive: true));
}