Package org.gudy.azureus2.core3.disk

Examples of org.gudy.azureus2.core3.disk.DiskManager


        return;
 
      if (piecesImage == null || piecesImage.isDisposed())
        return;
     
      DiskManager  dm = manager.getDiskManager();

      boolean valid = !bForce;
     
        boolean[] new_pieces = new boolean[manager.getNbPieces()];
           
      if ( dm != null ){
                   
          DiskManagerPiece[]  dm_pieces = dm.getPieces();
         
       for (int i=0;i<pieces.length;i++){
              
         new_pieces[i] = dm_pieces[i].isDone();
         }
View Full Code Here


  public void refresh(TableCell cell) {
    DiskManagerFileInfo fileInfo   = (DiskManagerFileInfo)cell.getDataSource();
 
    //   dm may be null if this is a skeleton file view
 
    DiskManager      dm      = fileInfo==null?null:fileInfo.getDiskManager();
 
    int remaining = 0;
   
    if( fileInfo != null && dm != null ) {
      int start = fileInfo.getFirstPieceNumber();
      int end = start + fileInfo.getNbPieces();
      DiskManagerPiece[] pieces = dm.getPieces();
      for( int i = start; i < end; i++ ) {
        if( !pieces[ i ].isDone() )  remaining++;
      }
    }else{
   
View Full Code Here

      if (args.size() < 2) {
        ci.out.println("> Command 'hack': Not enough parameters for subcommand 'file'.");
        return false;
      }
      try {
        DiskManager disk = dm.getDiskManager();
        DiskManagerFileInfo files[] = disk.getFiles();
        int file = Integer.parseInt((String) args.get(0));
        String c = (String) args.get(1);
        if (c.equalsIgnoreCase("normal") || c.equalsIgnoreCase("n")) {
          files[file - 1].setSkipped(false);
          files[file - 1].setPriority(0);
View Full Code Here

      return;
    }

    PEPeerManager pm = dlm.getPeerManager();

    DiskManager dm = dlm.getDiskManager();

    if (pm == null || dm == null) {
      GC gc = new GC(pieceInfoCanvas);
      gc.fillRectangle(bounds);
      gc.dispose();
      topLabel.setText("");

      return;
    }

    int iNumCols = bounds.width / BLOCK_SIZE;
    int iNeededHeight = (((dm.getNbPieces() - 1) / iNumCols) + 1) * BLOCK_SIZE;

    if (img != null && !img.isDisposed()) {
      Rectangle imgBounds = img.getBounds();
      if (imgBounds.width != bounds.width || imgBounds.height != iNeededHeight) {
        oldBlockInfo = null;
        img.dispose();
        img = null;
      }
    }

    DiskManagerPiece[] dm_pieces = dm.getPieces();

    PEPiece[] currentDLPieces = pm.getPieces();
    byte[] uploadingPieces = new byte[dm_pieces.length];

    // find upload pieces
View Full Code Here

      final int y1 = newHeight - borderWidth - 1;
     
      if (x1 < 10 || y1 < 3)
        return;
     
      final DiskManager manager = fileInfo.getDiskManager();
      // we want to run through the image part once one the transition from with a disk manager (running)
      // to without a disk manager (stopped) in order to clear the pieces view
      boolean running = manager != null;
      boolean hasGraphic = false;
      Graphic graphic = cell.getGraphic();
      if (graphic instanceof UISWTGraphic) {
        Image img = ((UISWTGraphic) graphic).getImage();
        hasGraphic = img != null && !img.isDisposed();
      }
      final boolean bImageBufferValid = (lastPercentDone == percentDone)
          && cell.isValid() && bNoRed && running == was_running && hasGraphic;
     
      if (bImageBufferValid)
        return;
     
      was_running = running;
      lastPercentDone = percentDone;
      Image piecesImage = null;
     
      if (graphic instanceof UISWTGraphic)
        piecesImage = ((UISWTGraphic) graphic).getImage();
      if (piecesImage != null && !piecesImage.isDisposed())
        piecesImage.dispose();
     
      if (!running) {
        cell.setGraphic(null);
        return;
      }
     
      piecesImage = new Image(SWTThread.getInstance().getDisplay(), newWidth, newHeight);
      final GC gcImage = new GC(piecesImage);
     
      // dm may be null if this is a skeleton file view
      DownloadManager download_manager = fileInfo.getDownloadManager();
      PEPeerManager peer_manager = download_manager == null ? null : download_manager.getPeerManager();
      PEPiece[] pe_pieces = peer_manager == null ? null : peer_manager.getPieces();
      final long now = SystemTime.getCurrentTime();
     
      if (fileInfo != null && manager != null)
      {
        if (percentDone == 1000)
        {
          gcImage.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
          gcImage.setBackground(Colors.blues[Colors.BLUES_DARKEST]);
          gcImage.fillRectangle(1, 1, newWidth - 2, newHeight - 2);
        } else
        {
          final int firstPiece = fileInfo.getFirstPieceNumber();
          final int nbPieces = fileInfo.getNbPieces();
          final DiskManagerPiece[] dm_pieces = manager.getPieces();
          bNoRed = true;
          for (int i = 0; i < newWidth; i++)
          {
            final int a0 = (i * nbPieces) / newWidth;
            int a1 = ((i + 1) * nbPieces) / newWidth;
View Full Code Here

    if ( download_manager == null ){
     
      return;
    }
   
    DiskManager    disk_manager = download_manager.getDiskManager();
    PEPeerManager  peer_manager = download_manager.getPeerManager();

    if (disk_manager == null || peer_manager == null ){
     
      return;
    }
   
    DiskManagerPiece[]   dm_pieces = disk_manager.getPieces();
    PEPiece[]      pe_pieces = peer_manager.getPieces();
   
    int  first_piece = file.getFirstPieceNumber();
    int  num_pieces  = file.getNbPieces();
   
View Full Code Here

      img = null;
    }

    DownloadManager  download_manager = file==null?null:file.getDownloadManager();
   
    DiskManager    disk_manager = download_manager==null?null:download_manager.getDiskManager();
    PEPeerManager  peer_manager = download_manager==null?null:download_manager.getPeerManager();
   
    if ( file == null || disk_manager == null || peer_manager == null ) {
      GC gc = new GC(fileInfoCanvas);
      gc.fillRectangle(bounds);
      gc.dispose();

      return;
    }

    int  first_piece = file.getFirstPieceNumber();
    int  num_pieces  = file.getNbPieces();
   
    int iNumCols = bounds.width / BLOCK_SIZE;
    int iNeededHeight = (((num_pieces - 1) / iNumCols) + 1)
        * BLOCK_SIZE;
    if (sc.getMinHeight() != iNeededHeight) {
      sc.setMinHeight(iNeededHeight);
      sc.layout(true, true);
      bounds = fileInfoCanvas.getClientArea();
    }

    img = new Image(fileInfoCanvas.getDisplay(), bounds.width, iNeededHeight);
    GC gcImg = new GC(img);

    try {
      gcImg.setBackground(fileInfoCanvas.getBackground());
      gcImg.fillRectangle(0, 0, bounds.width, bounds.height);


      DiskManagerPiece[]   dm_pieces = disk_manager.getPieces();
      PEPiece[]      pe_pieces = peer_manager.getPieces();

      int iRow = 0;
      int iCol = 0;
     
View Full Code Here

  }
 
    public void
    saveDownload()
    {
      DiskManager disk_manager = controller.getDiskManager();
   
      if ( disk_manager != null ){
     
        disk_manager.saveState();
      }
   
      download_manager_state.save();
    }
View Full Code Here

     
      TRTrackerAnnouncer  tc = tracker_client;
     
      if ( tc != null ){
       
        DiskManager  dm = getDiskManager();
       
          // only report "complete" if we really are complete, not a dnd completion event
       
        if ( dm != null && dm.getRemaining() == 0 ){
         
          tc.complete( never_downloaded );
        }
      }
  }
View Full Code Here

    if (current_save_location.equals(new_save_location)) {
        // null operation
      return;
    }

    DiskManager  dm = getDiskManager();
   
    if ( dm == null || dm.getFiles() == null){

      if ( !old_file.exists()){
         
        // files not created yet
         
        FileUtil.mkdirs(new_save_location.getParentFile());
         
        setTorrentSaveDir(new_save_location.getParent().toString(), new_save_location.getName());
       
        return;
      }
       
      try{
        new_save_location  = new_save_location.getCanonicalFile();
       
      }catch( Throwable e ){
       
        Debug.printStackTrace(e);
      }
     
      if ( old_file.equals( new_save_location )){
       
        // nothing to do
       
      } else if (torrent.isSimpleTorrent()) {
        // Have to keep the file name in sync if we're renaming.
        if (controller.getDiskManagerFileInfo()[0].setLinkAtomic(new_save_location)) {
          setTorrentSaveDir( new_save_location.getParentFile().toString(), new_save_location.getName());
        } else {throw new DownloadManagerException( "rename operation failed");}
       
      }else{

        if (FileUtil.isAncestorOf(old_file, new_save_location)) {
           
                Logger.logTextResource(new LogAlert(this, LogAlert.REPEATABLE,
              LogAlert.AT_ERROR, "DiskManager.alert.movefilefails"),
              new String[] {old_file.toString(), "Target is sub-directory of files" });
               
                throw( new DownloadManagerException( "rename operation failed" ));
        }
       
        // The files we move must be limited to those mentioned in the torrent.
        final HashSet files_to_move = new HashSet();

              // Required for the adding of parent directories logic.
              files_to_move.add(null);
              DiskManagerFileInfo[] info_files = controller.getDiskManagerFileInfo();
              for (int i=0; i<info_files.length; i++) {
                  File f = info_files[i].getFile(true);
                  try {f = f.getCanonicalFile();}
                  catch (IOException ioe) {f = f.getAbsoluteFile();}
                  boolean added_entry = files_to_move.add(f);

                  /**
                   * Start adding all the parent directories to the
                   * files_to_move list. Doesn't matter if we include
                   * files which are outside of the file path, the
                   * renameFile call won't try to move those directories
                   * anyway.
                   */
                  while (added_entry) {
                      f = f.getParentFile();
                      added_entry = files_to_move.add(f);
                  }
              }
        FileFilter ff = new FileFilter() {
          public boolean accept(File f) {return files_to_move.contains(f);}
        };
       
        if ( FileUtil.renameFile( old_file, new_save_location, false, ff )){
             
          setTorrentSaveDir( new_save_location.getParentFile().toString(), new_save_location.getName());
       
        }else{
         
          throw( new DownloadManagerException( "rename operation failed" ));
        }
      }
    }else{
      dm.moveDataFiles( new_save_location.getParentFile(), new_save_location.getName());
    }
  }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.disk.DiskManager

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.