FileDocCategorySizeDatePackage
FMFileTestImpl.javaAPI DocAzureus 3.0.3.43160Thu Feb 09 19:43:10 GMT 2006com.aelitis.azureus.core.diskmanager.file.impl

FMFileTestImpl

public class FMFileTestImpl extends FMFileUnlimited
author
parg

Fields Summary
protected long
file_offset_in_torrent
Constructors Summary
protected FMFileTestImpl(FMFileOwner _owner, FMFileManagerImpl _manager, File _file, int _type)

	
		super( _owner, _manager, _file, _type );
		
		TOTorrentFile	torrent_file = getOwner().getTorrentFile();
		
		TOTorrent	torrent = torrent_file.getTorrent();
							
		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();
		}
	
Methods Summary
protected voidreadSupport(org.gudy.azureus2.core3.util.DirectByteBuffer buffer, long offset)

		if ( AEDiagnostics.CHECK_DUMMY_FILE_DATA ){
			
			offset	+= file_offset_in_torrent;
			
			while( buffer.hasRemaining( DirectByteBuffer.SS_FILE )){
				
				buffer.put( DirectByteBuffer.SS_FILE, (byte)offset++ );
			}
		}else{
			
			buffer.position( DirectByteBuffer.SS_FILE, buffer.limit( DirectByteBuffer.SS_FILE ));
		}
	
protected voidwriteSupport(org.gudy.azureus2.core3.util.DirectByteBuffer[] buffers, long offset)

		offset	+= file_offset_in_torrent;
		
		for (int i=0;i<buffers.length;i++){
			
			DirectByteBuffer	buffer = buffers[i];
			
			if ( AEDiagnostics.CHECK_DUMMY_FILE_DATA ){

				while( buffer.hasRemaining( DirectByteBuffer.SS_FILE )){
					
					byte	v = buffer.get( DirectByteBuffer.SS_FILE );
					
					if ((byte)offset != v ){
						
						System.out.println( "FMFileTest: write is bad at " + offset +
											": expected = " + (byte)offset + ", actual = " + v );
	
						offset += buffer.remaining( DirectByteBuffer.SS_FILE ) + 1;
						
						break;
					}
					
					offset++;
				}
			}
			
			buffer.position( DirectByteBuffer.SS_FILE, buffer.limit( DirectByteBuffer.SS_FILE ));
		}