Package org.gudy.azureus2.core3.torrent

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


     
        // unfortunately the torrent's file order may not be ours...
     
      for ( int i=0;i<torrent_files.length;i++){

        TOTorrentFile tf = torrent_files[i];
       
        String rel_path = tf.getRelativePath();
       
        boolean  found = false;
       
        for (int j=0;j<source_files.length;j++){
         
View Full Code Here

            {
              return( owner.getCacheFileControlFileDir( ));
            }
          }, file, fm_type );
       
      TOTorrentFile  tf = owner.getCacheFileTorrentFile();
     
      CacheFile  cf;
     
      int  cache_mode = owner.getCacheMode();
     
      if ( cache_mode == CacheFileOwner.CACHE_MODE_EXPERIMENTAL ){
       
        cf = new CacheFileWithoutCacheMT( this, fm_file, tf );

      }else if (( tf != null && tf.getLength() < cache_files_not_smaller_than  ) || !cache_enabled || cache_mode == CacheFileOwner.CACHE_MODE_NO_CACHE ){
       
        cf = new CacheFileWithoutCache( this, fm_file, tf );
       
      }else{
       
View Full Code Here

        }
       
        long  flushed = cache_space_free - old_free;
       
        if (Logger.isEnabled()) {
          TOTorrentFile tf = file.getTorrentFile();
          TOTorrent torrent = tf == null ? null : tf.getTorrent();
          Logger.log(new LogEvent(torrent, LOGID,
              "DiskCache: cache full, flushed " + flushed + " from "
                  + oldest_file.getName()));
        }
       
        if ( flushed == 0 ){
       
          try{
            this_mon.enter();
           
            if cache_entries.size() > 0 &&
                (CacheEntry)cache_entries.keySet().iterator().next() == oldest_entry ){
             
                // hmm, something wrong with cache as the flush should have got rid
                // of at least the oldest entry
             
              throw( new CacheFileManagerException( null, "Cache inconsistent: 0 flushed"));
            }
          }finally{
           
            this_mon.exit();
          }
        }
      }
    }
         
    CacheEntry  entry = new CacheEntry( entry_type, file, buffer, file_position, length );
     
    if (log && Logger.isEnabled()) {
      TOTorrentFile tf = file.getTorrentFile();
      TOTorrent torrent = tf == null ? null : tf.getTorrent();

      Logger.log(new LogEvent(torrent, LOGID, "DiskCache: cr="
          + cache_bytes_read + ",cw=" + cache_bytes_written + ",fr="
          + file_bytes_read + ",fw=" + file_bytes_written));
    }
View Full Code Here

               
                CacheFileWithCache  file = (CacheFileWithCache)it.next();

                try{
                 
                  TOTorrentFile  tf = file.getTorrentFile();
                 
                  long  min_flush_size  = -1;
                 
                  if ( tf != null ){
                   
                    min_flush_size  = tf.getTorrent().getPieceLength();
                   
                  }
                 
                  file.flushOldDirtyData( oldest, min_flush_size );
                 
View Full Code Here

 
  protected void
  closeFile(
    CacheFileWithCache  file )
  {
    TOTorrentFile  tf = file.getTorrentFile();
   
    if ( tf != null && torrent_to_cache_file_map.get( tf ) != null ){

      try{
        this_mon.enter();
View Full Code Here

    Map localCacheMap = new LightHashMap();
   
    try {
      for(int i=0;i<files.length;i++)
      {
        TOTorrentFile  tf = files[i];
        long length = tf.getLength();
        fileOffsets[i] = fileOffset;
        if(firstFile == -1 && fileOffset <= first && first < fileOffset+length)
        {
          firstFile = i;
          this_mon.enter();
          lockAcquired = true;
        }
       
        if(fileOffset > last)
          break;

        if(lockAcquired)
        {
          CacheFileWithCache  cache_file = (CacheFileWithCache)torrent_to_cache_file_map.get( tf );
          localCacheMap.put(tf, cache_file);
        }

        fileOffset += length;
      }
    } finally {
      if(lockAcquired)
        this_mon.exit();
    }
   

   
    for (int i=firstFile;-1 < i && i <files.length;i++){
      TOTorrentFile  tf = files[i];
      CacheFileWithCache  cache_file = (CacheFileWithCache)localCacheMap.get( tf );
     
      long length = tf.getLength();
     
      fileOffset = fileOffsets[i];
      if(fileOffset > last)
        break;
     
View Full Code Here

       
        if( !files.contains( file )){
         
          files.add( file );
         
          TOTorrentFile torrentFile = file.getTorrentFile();
          String fileLength = "";
          try {
            fileLength = "" + file.getLength();
          } catch (Exception e) {
            if (torrentFile != null)
              fileLength = "" + torrentFile.getLength();
          }
          String  hash = "<unknown>";
         
          try{
            if (torrentFile != null)
              hash = ByteFormatter.encodeString( torrentFile.getTorrent().getHash());
           
          }catch( Throwable e ){
          }
         
          String name = file.getName();
View Full Code Here

         
      piece_size  = (int)torrent.getPieceLength();
                 
      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();
      }
     
      piece_offset  = piece_size - (int)( file_offset_in_torrent % piece_size );
     
      if ( piece_offset == piece_size ){
View Full Code Here

  protected boolean performCommand(ConsoleInput ci, DownloadManager dm, List args) {
    TOTorrent torrent = dm.getTorrent();
        if (torrent != null) {
          try {
          TRHost  host = ci.azureus_core.getTrackerHost();
         
          TRHostTorrent  existing = host.getHostTorrent( torrent );
         
          if ( existing == null ){
           
            host.publishTorrent(torrent);
          }else{
            try{
              existing.remove();
             
            }catch( Throwable e ){
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.torrent.TOTorrentFile

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.