installZipToTempDir function

String installZipToTempDir(
  1. Uint8List bytes, {
  2. String prefix = '',
  3. dynamic suffix = '',
  4. int trial = 0,
})

Installs zip bytes to temp dir and returns the full path of that directory

Implementation

String installZipToTempDir(
  Uint8List bytes, {
  String prefix = '',
  suffix = '',
  int trial = 0,
}) {
  var sha = md5(bytes);
  String fileName = prefix + sha + (trial == 0 ? '' : '_$trial') + suffix;
  String path = path_path.join(pathOfTempDir, fileName).replaceAll(r'\', '/');
  if (!directoryExists(path)) {
    String uuid = uuidTimeBased();
    unzipToDirectory(bytes, '$path.$uuid');
    try {
      pathRename('$path.$uuid', path);
    } catch (_) {}
  }
  if (unzipCheck(bytes, path)) {
    return path;
  }
  return installZipToTempDir(
    bytes,
    prefix: prefix,
    suffix: suffix,
    trial: trial + 1,
  );
}