ZipDirectory.read constructor

ZipDirectory.read(
  1. InputStream input,
  2. {String password}
)

Implementation

ZipDirectory.read(InputStream input, {String password}) {
  filePosition = _findSignature(input);
  input.offset = filePosition;
  final signature = input.readUint32(); // ignore: unused_local_variable
  numberOfThisDisk = input.readUint16();
  diskWithTheStartOfTheCentralDirectory = input.readUint16();
  totalCentralDirectoryEntriesOnThisDisk = input.readUint16();
  totalCentralDirectoryEntries = input.readUint16();
  centralDirectorySize = input.readUint32();
  centralDirectoryOffset = input.readUint32();

  final len = input.readUint16();
  if (len > 0) {
    zipFileComment = input.readString(size: len);
  }

  _readZip64Data(input);

  final dirContent =
      input.subset(centralDirectoryOffset, centralDirectorySize);

  while (!dirContent.isEOS) {
    final fileSig = dirContent.readUint32();
    if (fileSig != ZipFileHeader.SIGNATURE) {
      break;
    }
    fileHeaders.add(ZipFileHeader(dirContent, input, password));
  }
}