AsarFileSystem constructor

AsarFileSystem(
  1. ByteData bytes, {
  2. String? mount,
})

Implementation

AsarFileSystem(this.bytes, {
  String? mount
}) : super(mount) {
  int tag = bytes.getUint32(0, Endian.little);
  if (tag == 4) {
    int length = bytes.getInt32(4, Endian.little);
    tag = bytes.getInt32(8, Endian.little);
    if (tag + 4 == length) {
      int strlen = bytes.getInt32(12, Endian.little);
      if (strlen <= length) {
        var buf = bytes.buffer.asUint8List(bytes.offsetInBytes + 16, strlen);
        contentOffset = length + 8;
        var json = jsonDecode(utf8.decode(buf));
        _parseFile("", json);
      }
    } else {
      throw Exception("Can not parse Asar file");
    }
  } else {
    throw Exception("Can not parse Asar file");
  }
}