コード例 #1
0
  public TorrentFileSystem(int numHashes, TorrentFileSystemMemento torrentFileSystemMemento) {
    this._name = torrentFileSystemMemento.getName();
    this._totalSize = torrentFileSystemMemento.getTotalSize();
    this._files = torrentFileSystemMemento.getFiles();

    // BEGIN TODO remove this code after releasing a few versions Sept 2nd 2008.
    // There was a bug, where the file end piece would be set to numhashes instead of numhashes-1
    // the piece index is zero based. old code used to ignore these propblems, some of the newer
    // code throws an illegal argument exception.
    for (TorrentFile file : _files) {
      if (file.getEndPiece() == numHashes) {
        file.setEndPiece(numHashes - 1);
      }
    }
    // END TODO

    this._unmodFiles = Collections.unmodifiableList(_files);
    _folders.addAll(torrentFileSystemMemento.getFolders());
    this._incompleteFile = torrentFileSystemMemento.getIncompleteFile();
    this._completeFile = torrentFileSystemMemento.getCompleteFile();
  }