|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.klomp.snark.Storage
public class Storage
Maintains pieces on disk. Can be used to store and retrieve pieces.
Field Summary | |
---|---|
(package private) boolean |
changed
|
static int |
MAX_PIECE_SIZE
note that we start reducing max number of peer connections above 1MB |
static int |
MAX_PIECES
The maximum number of pieces in a torrent. |
static long |
MAX_TOTAL_SIZE
|
(package private) int |
piece_size
|
(package private) int |
pieces
|
Constructor Summary | |
---|---|
Storage(I2PSnarkUtil util,
java.io.File baseFile,
java.lang.String announce,
StorageListener listener)
Creates a storage from the existing file or directory together with an appropriate MetaInfo file as can be announced on the given announce String location. |
|
Storage(I2PSnarkUtil util,
MetaInfo metainfo,
StorageListener listener)
Creates a new storage based on the supplied MetaInfo. |
Method Summary | |
---|---|
void |
check(java.lang.String rootDir)
Creates (and/or checks) all files from the metainfo file list. |
void |
check(java.lang.String rootDir,
long savedTime,
BitField savedBitField)
use a saved bitfield and timestamp from a config file |
void |
cleanRAFs()
|
void |
close()
Closes the Storage and makes sure that all RandomAccessFiles are closed. |
boolean |
complete()
Whether or not this storage contains all pieces if the MetaInfo. |
void |
create()
|
java.lang.String |
getBaseName()
The base file or directory name of the data, as specified in the .torrent file, but filtered to remove illegal characters. |
BitField |
getBitField()
The BitField that tells which pieces this storage contains. |
static java.io.File |
getFileFromNames(java.io.File base,
java.util.List names)
|
MetaInfo |
getMetaInfo()
Returns the MetaInfo associated with this Storage. |
byte[] |
getPiece(int piece,
int off,
int len)
Returns a byte array containing a portion of the requested piece or null if the storage doesn't contain the piece yet. |
int |
needed()
How many pieces are still missing from this storage. |
boolean |
putPiece(int piece,
byte[] ba)
Put the piece in the Storage if it is correct. |
long |
remaining(java.lang.String file)
|
void |
reopen(java.lang.String rootDir)
Reopen the file descriptors for a restart Do existence check but no length check or data reverification |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
int piece_size
int pieces
boolean changed
public static final int MAX_PIECE_SIZE
public static final int MAX_PIECES
public static final long MAX_TOTAL_SIZE
Constructor Detail |
---|
public Storage(I2PSnarkUtil util, MetaInfo metainfo, StorageListener listener) throws java.io.IOException
java.io.IOException
- when creating and/or checking files fails.public Storage(I2PSnarkUtil util, java.io.File baseFile, java.lang.String announce, StorageListener listener) throws java.io.IOException
java.io.IOException
Method Detail |
---|
public void create() throws java.io.IOException
java.io.IOException
public MetaInfo getMetaInfo()
public int needed()
public boolean complete()
public long remaining(java.lang.String file)
file
- canonical path (non-directory)
public BitField getBitField()
public java.lang.String getBaseName()
public void check(java.lang.String rootDir) throws java.io.IOException
java.io.IOException
public void check(java.lang.String rootDir, long savedTime, BitField savedBitField) throws java.io.IOException
java.io.IOException
public void reopen(java.lang.String rootDir) throws java.io.IOException
java.io.IOException
public static java.io.File getFileFromNames(java.io.File base, java.util.List names)
public void close() throws java.io.IOException
java.io.IOException
public byte[] getPiece(int piece, int off, int len) throws java.io.IOException
java.io.IOException
public boolean putPiece(int piece, byte[] ba) throws java.io.IOException
java.io.IOException
- when some storage related error occurs.public void cleanRAFs()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |