installFromArchive method

Directory? installFromArchive({
  1. required File archivedFile,
  2. String? password,
  3. bool deleteIfExist = true,
  4. String fileSystemEntityIgnore = "",
})

Implementation

Directory? installFromArchive({
  required File archivedFile,
  String? password,
  bool deleteIfExist = true,
  String fileSystemEntityIgnore = "",
}) {
  if (Dart.isWeb) {
    return null;
  }

  Directory directory_ouput_temp =
      Directory(path.join(temp_directory.uri.toFilePath(), generateUuid(10)));

  if (directory_ouput_temp.existsSync()) {
    {
      int try_count = 0;
      while (true) {
        if (++try_count > 10) {
          throw "Error";
        }
        directory_ouput_temp = Directory(
            path.join(temp_directory.uri.toFilePath(), generateUuid(10)));
        if (directory_ouput_temp.existsSync() == false) {
          break;
        }
      }
    }
  }

  final Directory directory = ArchiveGeneralLib.extractArchiveZip(
    archivedFile: archivedFile,
    directoryOutput: directory_ouput_temp,
    password: password,
    verify: true,
    archiveGeneralLibOptions:
        ArchiveGeneralLibOptions(fileSystemEntityIgnore: """
.git
.dart_tool
$fileSystemEntityIgnore
""", isUseFileSystemEntityIgnore: true, isVerbose: false),
  );

  try {
    final Directory? directoryresult = installFromDirectory(
      directoryPackage: directory,
      deleteIfExist: deleteIfExist,
    );

    directory_ouput_temp.deleteSync(recursive: true);
    return directoryresult;
  } catch (e) {
    directory_ouput_temp.deleteSync(recursive: true);
    rethrow;
  }
}