Examples of TOTorrentFile


Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

        }
          };
 
          for (int i=0;i<res.length;i++){
 
              final TOTorrentFile torrent_file    = torrent_files[i];
 
              final int file_index = i;
 
              FileSkeleton info = new FileSkeleton() {
 
                private CacheFile   read_cache_file;
                // do not access this field directly, use lazyGetFile() instead
                private WeakReference dataFile = new WeakReference(null);
 
                public void
                setPriority(int b)
                {
                  priority    = b;
 
                  DiskManagerImpl.storeFilePriorities( download_manager, res );
 
                  listener.filePriorityChanged( this );
                }
 
                public void
                setSkipped(boolean _skipped)
                {
                  if ( !_skipped && getStorageType() == ST_COMPACT ){
                    if ( !setStorageType( ST_LINEAR )){
                      return;
                    }
                  }
 
                  if ( !_skipped && getStorageType() == ST_REORDER_COMPACT ){
                    if ( !setStorageType( ST_REORDER )){
                      return;
                    }
                  }

                  skipped = _skipped;
 
                  DiskManagerImpl.storeFilePriorities( download_manager, res );
                 
                  if(!_skipped)
                  {
                    boolean[] toCheck = new boolean[fileSetSkeleton.nbFiles()];
                    toCheck[file_index] = true;
                    doFileExistenceChecks(fileSetSkeleton, toCheck, download_manager, true);                     
                  }
                 
 
                  listener.filePriorityChanged( this );
                }
 
                public int
                getAccessMode()
                {
                  return( READ );
                }
 
                public long
                getDownloaded()
                {
                  return( downloaded );
                }
 
                public void
                setDownloaded(
                  long    l )
                {
                  downloaded  = l;
                }
 
                public String
                getExtension()
                {
                  String    ext   = lazyGetFile().getName();
                 
                      if ( incomplete_suffix != null && ext.endsWith( incomplete_suffix )){
                       
                        ext = ext.substring( 0, ext.length() - incomplete_suffix.length());
                      }

                  int separator = ext.lastIndexOf(".");
                  if (separator == -1)
                    separator = 0;
                  return ext.substring(separator);
                }
 
                public int
                getFirstPieceNumber()
                {
                  return( torrent_file.getFirstPieceNumber());
                }
 
                public int
                getLastPieceNumber()
                {
                  return( torrent_file.getLastPieceNumber());
                }
 
                public long
                getLength()
                {
                  return( torrent_file.getLength());
                }
 
                public int
                getIndex()
                {
                  return( file_index );
                }
 
                public int
                getNbPieces()
                {
                  return( torrent_file.getNumberOfPieces());
                }
 
                public int
                getPriority()
                {
                  return( priority );
                }
 
                public boolean
                isSkipped()
                {
                  return( skipped );
                }
 
                public DiskManager
                getDiskManager()
                {
                  return( null );
                }
 
                public DownloadManager
                getDownloadManager()
                {
                  return( download_manager );
                }
 
                public File
                getFile(
                  boolean follow_link )
                {
                  if ( follow_link ){
 
                    File link = getLink();
 
                    if ( link != null ){
 
                      return( link );
                    }
                  }
                  return lazyGetFile();
                }
 
                private File lazyGetFile()
                {
                  File toReturn = (File)dataFile.get();
                  if(toReturn != null)
                    return toReturn;
 
                  TOTorrent tor = download_manager.getTorrent();
 
                  String  path_str = root_dir;
                  File simpleFile = null;
 
                  // for a simple torrent the target file can be changed
 
                  if ( tor.isSimpleTorrent()){
 
                    simpleFile = download_manager.getAbsoluteSaveLocation();
 
                  }else{
                    byte[][]path_comps = torrent_file.getPathComponents();
 
                    for (int j=0;j<path_comps.length;j++){
 
                      String comp;
                      try
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

    TOTorrentFile[] files = torrent.getFiles();

    for (int i = 0; i < files.length; i++) {

      TOTorrentFile file = files[i];

      byte[][] comps = file.getPathComponents();

      for (int j = 0; j < comps.length; j++) {
        candidateDecoders = localeUtil.getCandidateDecoders(comps[j]);
        if (candidateDecoders.size() < lMinCandidates) {
          lMinCandidates = candidateDecoders.size();
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

    synchronized( DiskManagerChannelImpl.class ){
     
      channel_id = channel_id_next++;
    }
       
    TOTorrentFile  tf = core_file.getTorrentFile();
   
    TOTorrent   torrent = tf.getTorrent();
   
    TOTorrentFile[]  tfs = torrent.getFiles();

    rtas  = new long[torrent.getNumberOfPieces()];
   
    core_download.addPeerListener( this );
     
    for (int i=0;i<core_file.getIndex();i++){
       
      file_offset_in_torrent += tfs[i].getLength();
    }
     
    piece_size  = tf.getTorrent().getPieceLength();
   
    core_file.addListener( this );
   
    reportCreated( this );
  }
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

                   
                    PeerManagerRegistration reg_data = PeerManager.getSingleton().manualMatchLink( address, link );
                   
                    if ( reg_data != null ){

                      TOTorrentFile  file = reg_data.getLink( link );
                     
                      if ( file != null ){
                       
                        StringBuffer  target_url = new StringBuffer( 512 );
                       
                        target_url.append( "/files/" );
                       
                        target_url.append( URLEncoder.encodenew String( file.getTorrent().getHash(), "ISO-8859-1" ), "ISO-8859-1" ));
                       
                        byte[][]  bits = file.getPathComponents();
                       
                        for (int i=0;i<bits.length;i++){
                         
                          target_url.append( "/" );
                         
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

           
            file_offset  = 0;
           
            for (int j=0;j<files.length;j++){
             
              TOTorrentFile  torrent_file = files[j].getTorrentFile();
             
              byte[][]  comps = torrent_file.getPathComponents();
             
              if ( comps.length == bits.size()){
               
                boolean  match = true;
               
                for (int k=0;k<comps.length;k++){
                                                 
                  if ( !Arrays.equals( comps[k], (byte[])bits.get(k))){
                   
                    match  = false;
                   
                    break;
                  }
                }
               
                if ( match ){
                 
                  target_file   = files[j];
                                 
                  break;
                }
              }
             
              file_offset += torrent_file.getLength();
            }
          }
        }else{
         
          line = line.toLowerCase( MessageText.LOCALE_ENGLISH );
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

     
      base_url += "/" + URLEncoder.encode( new String( to_torrent.getName(), "ISO-8859-1" ), "ISO-8859-1" ).replaceAll("\\+", "%20");
     
      for (int i=0;i<files.length;i++ ){
       
        TOTorrentFile  file = files[i];
       
        long length = file.getLength();
         
        String  file_url_str = base_url;
       
        byte[][] bits = file.getPathComponents();
       
        for (int j=0;j<bits.length;j++){
         
          file_url_str += "/" + URLEncoder.encode( new String( bits[j], "ISO-8859-1" ), "ISO-8859-1" ).replaceAll("\\+", "%20");
        }
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

     
      int  read_access     = 0;
      int write_access    = 0;
      int  write_access_lax  = 0;
     
      TOTorrentFile  my_torrent_file = owner.getTorrentFile();
     
      String  users = "";
       
      for (Iterator it=owners.iterator();it.hasNext();){
       
        Object[]  entry = (Object[])it.next();
         
        FMFileOwner  this_owner = (FMFileOwner)entry[0];
       
        if (((Boolean)entry[1]).booleanValue()){
                   
          write_access++;
         
          TOTorrentFile this_tf = this_owner.getTorrentFile();
         
          if ( my_torrent_file != null && this_tf != null && my_torrent_file.getLength() == this_tf.getLength()){
           
            write_access_lax++;
          }
         
          users += (users.length()==0?"":",") + this_owner.getName() + " [write]";
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

     
      long  file_offset_in_torrent = 0;
     
      for (int i=0;i<torrent.getFiles().length;i++){
       
        TOTorrentFile  f = torrent.getFiles()[i];
       
        if ( f == torrent_file ){
         
          break;
        }
       
        file_offset_in_torrent  += f.getLength();
      }
     
      int piece_offset  = piece_size - (int)( file_offset_in_torrent % piece_size );
     
      if ( piece_offset == piece_size ){
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

  }
 
  protected void
  setControlFile()
  {
    TOTorrentFile  tf = owner.getOwner().getTorrentFile();
   
    if ( tf == null ){

      controlFileName = null;
      control_dir = null;
    }
   
    TOTorrent  torrent = tf.getTorrent();
   
    TOTorrentFile[]  files = torrent.getFiles();
   
    int  file_index = -1;
   
View Full Code Here

Examples of org.gudy.azureus2.core3.torrent.TOTorrentFile

       
        TOTorrentFile[] files = torrent.getFiles();
       
        for (int i=0;i<files.length;i++){
         
          TOTorrentFile  f = files[i];
         
          if ( f == _torrent_file ){
           
            break;
          }
         
          file_offset_in_torrent  += f.getLength();
        }
                               
        int first_piece_offset   = (int)( file_offset_in_torrent % piece_size );

        first_piece_length  = piece_size - first_piece_offset;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.