Package com.biglybt.core.disk.impl
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 DiskManagerHelper
private long
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl>
(package private) AverageFactory.LazyMovingImmediateAverageState
private String
(package private) final int
private String
private int
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl>
(package private) AverageFactory.LazyMovingImmediateAverageState
private final String
private File
protected boolean
private Boolean
(package private) final TOTorrentFile
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl>
(package private) AverageFactory.LazyMovingImmediateAverageState
Fields inherited from interface com.biglybt.core.diskmanager.cache.CacheFileOwner
CACHE_MODE_EXPERIMENTAL, CACHE_MODE_NO_CACHE, CACHE_MODE_NORMAL
Fields inherited from interface com.biglybt.core.disk.DiskManagerFileInfo
READ, ST_COMPACT, ST_LINEAR, ST_REORDER, ST_REORDER_COMPACT, WRITE
-
Constructor Summary
ConstructorsConstructorDescriptionDiskManagerFileInfoImpl
(DiskManagerHelper _disk_manager, File _root_dir, String _relative_file, int _file_index, TOTorrentFile _torrent_file, int _storage_type) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(DiskManagerFileInfoListener listener) void
close()
void
dataChecked
(long offset, long size) void
dataWritten
(long offset, long size, Object originator) boolean
exists()
Checks that the linked file exists (always returns true for pad files)void
int
int
long
long
getETA()
getFile
(boolean follow_link) int
int
getIndex()
long
int
long
getLink()
int
int
File Download Priorityint
int
Returns the storage type for this fileint
boolean
Skipped files don't get downloaded.protected void
load
(int _priority, boolean _skipped) void
moveFile
(File new_root_dir, File new_absolute_file, boolean link_only, FileUtil.ProgressListener pl) read
(long offset, int length) void
recheck()
void
removeListener
(DiskManagerFileInfoListener listener) void
renameFile
(String new_name) void
setAccessMode
(int mode) void
setDownloaded
(long l) void
setExtension
(String string) boolean
Relink 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).boolean
setLinkAtomic
(File link_destination, boolean no_delete) boolean
setLinkAtomic
(File link_destination, boolean no_delete, FileUtil.ProgressListener pl) void
setPriority
(int b) void
setSkipped
(boolean skipped) protected void
setSkippedInternal
(boolean _skipped) boolean
setStorageType
(int type, boolean force) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.biglybt.core.disk.DiskManagerFileInfo
isLinked, 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, String _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:
getCacheFileOwnerName
in interfaceCacheFileOwner
-
getCacheFileTorrentFile
- Specified by:
getCacheFileTorrentFile
in interfaceCacheFileOwner
-
getCacheFileControlFileDir
- Specified by:
getCacheFileControlFileDir
in interfaceCacheFileOwner
-
getCacheMode
public int getCacheMode()- Specified by:
getCacheMode
in interfaceCacheFileOwner
-
flushCache
- Specified by:
flushCache
in interfaceDiskManagerFileInfo
- Throws:
Exception
-
exists
public boolean exists()Description copied from interface:DiskManagerFileInfo
Checks that the linked file exists (always returns true for pad files)- Specified by:
exists
in 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:
getAccessMode
in interfaceDiskManagerFileInfo
-
getDownloaded
public long getDownloaded()- Specified by:
getDownloaded
in interfaceDiskManagerFileInfo
- Returns:
-
getLastModified
public long getLastModified()- Specified by:
getLastModified
in interfaceDiskManagerFileInfo
-
getExtension
- Specified by:
getExtension
in interfaceDiskManagerFileInfo
- Returns:
-
getFile
- Specified by:
getFile
in interfaceDiskManagerFileInfo
- Returns:
-
getTorrentFile
- Specified by:
getTorrentFile
in interfaceDiskManagerFileInfo
-
setLink
Description copied from interface:DiskManagerFileInfo
Relink 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:
setLink
in interfaceDiskManagerFileInfo
- Returns:
- true - worked, false - failed, use getLastError to possibly get some extra info
-
getLastError
- Specified by:
getLastError
in interfaceDiskManagerFileInfo
-
setLinkAtomic
- Specified by:
setLinkAtomic
in interfaceDiskManagerFileInfo
-
setLinkAtomic
public boolean setLinkAtomic(File link_destination, boolean no_delete, FileUtil.ProgressListener pl) - Specified by:
setLinkAtomic
in interfaceDiskManagerFileInfo
-
getLink
- Specified by:
getLink
in interfaceDiskManagerFileInfo
-
setStorageType
public boolean setStorageType(int type, boolean force) - Specified by:
setStorageType
in interfaceDiskManagerFileInfo
force
- discards any existing file content if it exists - use with care...- Returns:
-
getStorageType
public int getStorageType()Description copied from interface:DiskManagerFileInfo
Returns the storage type for this file- Specified by:
getStorageType
in interfaceDiskManagerFileInfo
- Returns:
DiskManagerFileInfo.ST_LINEAR
,DiskManagerFileInfo.ST_COMPACT
,DiskManagerFileInfo.ST_REORDER
,DiskManagerFileInfo.ST_REORDER_COMPACT
-
getFirstPieceNumber
public int getFirstPieceNumber()- Specified by:
getFirstPieceNumber
in interfaceDiskManagerFileInfo
- Returns:
-
getLastPieceNumber
public int getLastPieceNumber()- Specified by:
getLastPieceNumber
in interfaceDiskManagerFileInfo
-
getLength
public long getLength()- Specified by:
getLength
in interfaceDiskManagerFileInfo
- Returns:
-
getIndex
public int getIndex()- Specified by:
getIndex
in interfaceDiskManagerFileInfo
-
getNbPieces
public int getNbPieces()- Specified by:
getNbPieces
in interfaceDiskManagerFileInfo
- Returns:
-
setDownloaded
public void setDownloaded(long l) - Parameters:
l
-
-
setExtension
- Parameters:
string
-
-
getPriority
public int getPriority()Description copied from interface:DiskManagerFileInfo
File Download Priority- Specified by:
getPriority
in interfaceDiskManagerFileInfo
- Returns:
-
setPriority
public void setPriority(int b) - Specified by:
setPriority
in interfaceDiskManagerFileInfo
- Parameters:
b
-
-
isSkipped
public boolean isSkipped()Description copied from interface:DiskManagerFileInfo
Skipped files don't get downloaded. The state of the existing data is dependent uponDiskManagerFileInfo.getStorageType()
. StatesDiskManagerFileInfo.ST_COMPACT
andDiskManagerFileInfo.ST_REORDER_COMPACT
will delete (or trim) the file. Other states will retain existing data (ie. Do Not Download).- Specified by:
isSkipped
in interfaceDiskManagerFileInfo
- Returns:
-
setSkipped
public void setSkipped(boolean skipped) - Specified by:
setSkipped
in interfaceDiskManagerFileInfo
- Parameters:
skipped
-
-
isSkipping
- Specified by:
isSkipping
in interfaceDiskManagerFileInfo
-
setSkippedInternal
protected void setSkippedInternal(boolean _skipped) -
getDiskManager
- Specified by:
getDiskManager
in interfaceDiskManagerFileInfo
-
getDownloadManager
- Specified by:
getDownloadManager
in interfaceDiskManagerFileInfo
-
dataWritten
-
dataChecked
public void dataChecked(long offset, long size) -
read
- Specified by:
read
in interfaceDiskManagerFileInfo
- Throws:
IOException
-
getReadBytesPerSecond
public int getReadBytesPerSecond()- Specified by:
getReadBytesPerSecond
in interfaceDiskManagerFileInfo
-
getWriteBytesPerSecond
public int getWriteBytesPerSecond()- Specified by:
getWriteBytesPerSecond
in interfaceDiskManagerFileInfo
-
getETA
public long getETA()- Specified by:
getETA
in interfaceDiskManagerFileInfo
-
recheck
public void recheck()- Specified by:
recheck
in interfaceDiskManagerFileInfo
-
close
public void close()- Specified by:
close
in interfaceDiskManagerFileInfo
-
addListener
- Specified by:
addListener
in interfaceDiskManagerFileInfo
-
removeListener
- Specified by:
removeListener
in interfaceDiskManagerFileInfo
-