Class DiskManagerFileInfoImpl
java.lang.Object
com.biglybt.core.disk.impl.DiskManagerFileInfoImpl
- All Implemented Interfaces:
DiskManagerFileInfo, CacheFileOwner
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) CacheFile(package private) final DiskManagerHelperprivate longprivate static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> (package private) AverageFactory.LazyMovingImmediateAverageStateprivate String(package private) final intprivate Stringprivate intprivate static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> (package private) AverageFactory.LazyMovingImmediateAverageStateprivate final StringInterner.FileKeyprivate Fileprotected booleanprivate Boolean(package private) final TOTorrentFileprivate static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> (package private) AverageFactory.LazyMovingImmediateAverageStateFields inherited from interface CacheFileOwner
CACHE_MODE_EXPERIMENTAL, CACHE_MODE_NO_CACHE, CACHE_MODE_NORMALFields inherited from interface DiskManagerFileInfo
READ, ST_COMPACT, ST_LINEAR, ST_REORDER, ST_REORDER_COMPACT, WRITE -
Constructor Summary
ConstructorsConstructorDescriptionDiskManagerFileInfoImpl(DiskManagerHelper _disk_manager, File _root_dir, StringInterner.FileKey _relative_file, int _file_index, TOTorrentFile _torrent_file, int _storage_type) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(DiskManagerFileInfoListener listener) voidclose()voiddataChecked(long offset, long size) voiddataWritten(long offset, long size, Object originator) booleanexists()Checks that the linked file exists (always returns true for pad files)voidintintlonglonggetETA()getFile(boolean follow_link) longintintgetIndex()longintlonggetLink()intintFile Download PriorityintintReturns the storage type for this fileintbooleanSkipped files don't get downloaded.protected voidload(int _priority, boolean _skipped) voidmoveFile(File new_root_dir, File new_absolute_file, boolean link_only, FileUtil.ProgressListener pl) read(long offset, int length) voidrecheck()voidremoveListener(DiskManagerFileInfoListener listener) voidrenameFile(String new_name) voidsetAccessMode(int mode) voidsetDownloaded(long l) voidsetExtension(String string) booleanRelink the file to the destination given - this method deals with if the file is part of a simple torrent or not (so it may set the download name to keep it in sync).booleansetLinkAtomic(File link_destination, boolean no_delete) booleansetLinkAtomic(File link_destination, boolean no_delete, FileUtil.ProgressListener pl) voidsetPriority(int b) voidsetSkipped(boolean skipped) protected voidsetSkippedInternal(boolean _skipped) booleansetStorageType(int type, boolean force) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DiskManagerFileInfo
isLinked, isMetadataDownload, setStorageType
-
Field Details
-
root_dir
-
relative_file
-
file_index
final int file_index -
cache_file
CacheFile cache_file -
extension
-
downloaded
private long downloaded -
diskManager
-
torrent_file
-
priority
private int priority -
skipped_internal
protected boolean skipped_internal -
skipping
-
last_error
-
listeners
-
read_average_state
-
write_average_state
-
eta_average_state
-
read_adapter
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> read_adapter -
write_adapter
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> write_adapter -
eta_adapter
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> eta_adapter
-
-
Constructor Details
-
DiskManagerFileInfoImpl
public DiskManagerFileInfoImpl(DiskManagerHelper _disk_manager, File _root_dir, StringInterner.FileKey _relative_file, int _file_index, TOTorrentFile _torrent_file, int _storage_type) throws CacheFileManagerException - Throws:
CacheFileManagerException
-
-
Method Details
-
load
protected void load(int _priority, boolean _skipped) -
getCacheFileOwnerName
- Specified by:
getCacheFileOwnerNamein interfaceCacheFileOwner
-
getCacheFileTorrentFile
- Specified by:
getCacheFileTorrentFilein interfaceCacheFileOwner
-
getCacheFileControlFileDir
- Specified by:
getCacheFileControlFileDirin interfaceCacheFileOwner
-
getCacheMode
public int getCacheMode()- Specified by:
getCacheModein interfaceCacheFileOwner
-
getCacheFileLink
- Specified by:
getCacheFileLinkin interfaceCacheFileOwner
-
getFileAllocationStrategy
public long getFileAllocationStrategy()- Specified by:
getFileAllocationStrategyin interfaceCacheFileOwner
-
flushCache
- Specified by:
flushCachein interfaceDiskManagerFileInfo- Throws:
Exception
-
exists
public boolean exists()Description copied from interface:DiskManagerFileInfoChecks that the linked file exists (always returns true for pad files)- Specified by:
existsin interfaceDiskManagerFileInfo- Returns:
-
moveFile
public void moveFile(File new_root_dir, File new_absolute_file, boolean link_only, FileUtil.ProgressListener pl) throws CacheFileManagerException - Throws:
CacheFileManagerException
-
renameFile
- Throws:
CacheFileManagerException
-
getCacheFile
-
setAccessMode
- Throws:
CacheFileManagerException
-
getAccessMode
public int getAccessMode()- Specified by:
getAccessModein interfaceDiskManagerFileInfo
-
getDownloaded
public long getDownloaded()- Specified by:
getDownloadedin interfaceDiskManagerFileInfo- Returns:
-
getLastModified
public long getLastModified()- Specified by:
getLastModifiedin interfaceDiskManagerFileInfo
-
getExtension
- Specified by:
getExtensionin interfaceDiskManagerFileInfo- Returns:
-
getFile
- Specified by:
getFilein interfaceDiskManagerFileInfo- Returns:
-
getTorrentFile
- Specified by:
getTorrentFilein interfaceDiskManagerFileInfo
-
setLink
Description copied from interface:DiskManagerFileInfoRelink the file to the destination given - this method deals with if the file is part of a simple torrent or not (so it may set the download name to keep it in sync). If you just want a simple relink, use setLinkAtomic.- Specified by:
setLinkin interfaceDiskManagerFileInfo- Parameters:
link_destination-- Returns:
- true - worked, false - failed, use getLastError to possibly get some extra info
-
getLastError
- Specified by:
getLastErrorin interfaceDiskManagerFileInfo
-
setLinkAtomic
- Specified by:
setLinkAtomicin interfaceDiskManagerFileInfo
-
setLinkAtomic
public boolean setLinkAtomic(File link_destination, boolean no_delete, FileUtil.ProgressListener pl) - Specified by:
setLinkAtomicin interfaceDiskManagerFileInfo
-
getLink
- Specified by:
getLinkin interfaceDiskManagerFileInfo
-
setStorageType
public boolean setStorageType(int type, boolean force) - Specified by:
setStorageTypein interfaceDiskManagerFileInfo- Parameters:
type-force- discards any existing file content if it exists - use with care...- Returns:
-
getStorageType
public int getStorageType()Description copied from interface:DiskManagerFileInfoReturns the storage type for this file- Specified by:
getStorageTypein interfaceDiskManagerFileInfo- Returns:
DiskManagerFileInfo.ST_LINEAR,DiskManagerFileInfo.ST_COMPACT,DiskManagerFileInfo.ST_REORDER,DiskManagerFileInfo.ST_REORDER_COMPACT
-
getFirstPieceNumber
public int getFirstPieceNumber()- Specified by:
getFirstPieceNumberin interfaceDiskManagerFileInfo- Returns:
-
getLastPieceNumber
public int getLastPieceNumber()- Specified by:
getLastPieceNumberin interfaceDiskManagerFileInfo
-
getLength
public long getLength()- Specified by:
getLengthin interfaceDiskManagerFileInfo- Returns:
-
getIndex
public int getIndex()- Specified by:
getIndexin interfaceDiskManagerFileInfo
-
getNbPieces
public int getNbPieces()- Specified by:
getNbPiecesin interfaceDiskManagerFileInfo- Returns:
-
setDownloaded
public void setDownloaded(long l) - Parameters:
l-
-
setExtension
- Parameters:
string-
-
getPriority
public int getPriority()Description copied from interface:DiskManagerFileInfoFile Download Priority- Specified by:
getPriorityin interfaceDiskManagerFileInfo- Returns:
-
setPriority
public void setPriority(int b) - Specified by:
setPriorityin interfaceDiskManagerFileInfo- Parameters:
b-
-
isSkipped
public boolean isSkipped()Description copied from interface:DiskManagerFileInfoSkipped files don't get downloaded. The state of the existing data is dependent uponDiskManagerFileInfo.getStorageType(). StatesDiskManagerFileInfo.ST_COMPACTandDiskManagerFileInfo.ST_REORDER_COMPACTwill delete (or trim) the file. Other states will retain existing data (ie. Do Not Download).- Specified by:
isSkippedin interfaceDiskManagerFileInfo- Returns:
-
setSkipped
public void setSkipped(boolean skipped) - Specified by:
setSkippedin interfaceDiskManagerFileInfo- Parameters:
skipped-
-
isSkipping
- Specified by:
isSkippingin interfaceDiskManagerFileInfo
-
setSkippedInternal
protected void setSkippedInternal(boolean _skipped) -
getDiskManager
- Specified by:
getDiskManagerin interfaceDiskManagerFileInfo
-
getDownloadManager
- Specified by:
getDownloadManagerin interfaceDiskManagerFileInfo
-
dataWritten
-
dataChecked
public void dataChecked(long offset, long size) -
read
- Specified by:
readin interfaceDiskManagerFileInfo- Throws:
IOException
-
getReadBytesPerSecond
public int getReadBytesPerSecond()- Specified by:
getReadBytesPerSecondin interfaceDiskManagerFileInfo
-
getWriteBytesPerSecond
public int getWriteBytesPerSecond()- Specified by:
getWriteBytesPerSecondin interfaceDiskManagerFileInfo
-
getETA
public long getETA()- Specified by:
getETAin interfaceDiskManagerFileInfo
-
recheck
public void recheck()- Specified by:
recheckin interfaceDiskManagerFileInfo
-
close
public void close()- Specified by:
closein interfaceDiskManagerFileInfo
-
addListener
- Specified by:
addListenerin interfaceDiskManagerFileInfo
-
removeListener
- Specified by:
removeListenerin interfaceDiskManagerFileInfo
-