Package com.torrent4j.model.metadata

Examples of com.torrent4j.model.metadata.MetadataInfo


    this.strategy = strategy;
    this.metadata = metadata;
    this.hash = new TorrentHash(this, metadata.getInfoHash());

    // parse file list
    final MetadataInfo info = metadata.getInfo();
    final byte[] pieceHashes = info.getPieceHashes();
    final int pieces = pieceHashes.length / 20;
    long piecesLength = 0;
    for (int i = 0; i < pieces; i++) {
      final byte[] hash = Arrays.copyOfRange(pieceHashes, i * 20,
          (i + 1) * 20);
      final int length = (int) (i + 1 == pieces ? (info.getLength() - piecesLength)
          : info.getPieceLength());

      this.pieces.add(new TorrentPiece(this, hash, i, info
          .getPieceLength() * i, length));
      piecesLength += length;
    }

    final Path torrentPath = Paths.get(info.getName());
    long offset = 0;
    for (final MetadataFile metaFile : info.getFiles()) {
      byte[] hash = null;
      if (metaFile.getHash() != null)
        hash = MD5.fromString(metaFile.getHash());
      final List<TorrentPiece> filePieces = getPieces(Range
          .getRangeByLength(offset, metaFile.getLength()));
View Full Code Here

TOP

Related Classes of com.torrent4j.model.metadata.MetadataInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.