Package org.eclipse.ecf.protocol.bittorrent.internal.torrent

Examples of org.eclipse.ecf.protocol.bittorrent.internal.torrent.DataFile


  private void fileInitialization(String[] filenames, File targetFile)
      throws IOException {
    if (files.length == 1) {
      long length = torrent.getLengths()[0];
      files[0] = new DataFile(targetFile, length);
      int[] pieces = new int[torrent.getPieces().length];
      for (int i = 0; i < pieces.length; i++) {
        pieces[i] = i;
      }
      files[0].setPieces(pieces, pieceLength, pieceLength);
      remaining = length;
    } else {
      int count = 0;
      int piece = 0;
      int currentLength = pieceLength;
      for (int i = 0; i < filenames.length; i++) {
        File file = new File(targetFile + File.separator + filenames[i]);
        if (!file.getParentFile().exists()
            && !file.getParentFile().mkdirs()) {
          throw new IOException("The folders needed by this torrent could not be created"); //$NON-NLS-1$
        }

        long fileLength = torrent.getLengths()[i];
        files[i] = new DataFile(file, fileLength);

        if (currentLength > fileLength) {
          files[i].setPieces(new int[] { count }, (int) fileLength,
              (int) fileLength);
          currentLength -= fileLength;
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.protocol.bittorrent.internal.torrent.DataFile

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.