Class FMFileAccessPieceReorderer
java.lang.Object
com.biglybt.core.diskmanager.file.impl.FMFileAccessPieceReorderer
- All Implemented Interfaces:
FMFileAccess
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.biglybt.core.diskmanager.file.impl.FMFileAccess
FMFileAccess.FileAccessor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final File
private final String
private long
private final FMFileAccess
private static final int
private static final int
private static final long
private static final int
private int
private long
private int
private int
private int
private static final int
private int
private int
private int[]
private int[]
private int
private int
private static final byte
private final int
private static final boolean
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
FMFileAccessPieceReorderer
(TOTorrentFile _torrent_file, File _control_dir, String _control_file, int _storage_type, FMFileAccess _delegate) -
Method Summary
Modifier and TypeMethodDescriptionvoid
private void
configBorked
(String error) private static Map
encodeConfig
(int storage_type, long current_length, long next_piece_index, int[] piece_map) void
flush()
getFile()
long
protected int
getPieceIndex
(FMFileAccess.FileAccessor fa, int piece_number, boolean allocate_if_needed) protected long
getPieceOffset
(FMFileAccess.FileAccessor fa, int piece_number, boolean allocate_if_needed) boolean
isPieceCompleteProcessingNeeded
(int piece_number) void
read
(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position) private void
protected void
readWrite
(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position, boolean is_read) protected int
readWritePiece
(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, int piece_number, int piece_offset, boolean is_read) protected static void
recoverConfig
(TOTorrentFile torrent_file, File data_file, File config_file, int storage_type) protected void
setDirty()
void
setLength
(FMFileAccess.FileAccessor fa, long length) void
setPieceComplete
(FMFileAccess.FileAccessor fa, int piece_number, DirectByteBuffer piece_data) void
write
(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position) private void
-
Field Details
-
TRACE
private static final boolean TRACE- See Also:
-
MIN_PIECES_REORDERABLE
private static final int MIN_PIECES_REORDERABLE- See Also:
-
SS_FILE
private static final byte SS_FILE- See Also:
-
DIRT_CLEAN
private static final int DIRT_CLEAN- See Also:
-
DIRT_DIRTY
private static final int DIRT_DIRTY- See Also:
-
DIRT_NEVER_WRITTEN
private static final int DIRT_NEVER_WRITTEN- See Also:
-
DIRT_FLUSH_MILLIS
private static final long DIRT_FLUSH_MILLIS- See Also:
-
delegate
-
control_dir
-
control_file
-
storage_type
private final int storage_type -
piece_size
private int piece_size -
first_piece_length
private int first_piece_length -
first_piece_number
private int first_piece_number -
last_piece_length
private int last_piece_length -
num_pieces
private int num_pieces -
previous_storage_type
private int previous_storage_type -
current_length
private long current_length -
piece_map
private int[] piece_map -
piece_reverse_map
private int[] piece_reverse_map -
next_piece_index
private int next_piece_index -
dirt_state
private int dirt_state -
dirt_time
private long dirt_time
-
-
Constructor Details
-
FMFileAccessPieceReorderer
protected FMFileAccessPieceReorderer(TOTorrentFile _torrent_file, File _control_dir, String _control_file, int _storage_type, FMFileAccess _delegate) throws FMFileManagerException - Throws:
FMFileManagerException
-
-
Method Details
-
aboutToOpen
- Specified by:
aboutToOpen
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
getLength
- Specified by:
getLength
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
setLength
- Specified by:
setLength
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
getPieceOffset
protected long getPieceOffset(FMFileAccess.FileAccessor fa, int piece_number, boolean allocate_if_needed) throws FMFileManagerException - Throws:
FMFileManagerException
-
readWritePiece
protected int readWritePiece(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, int piece_number, int piece_offset, boolean is_read) throws FMFileManagerException - Throws:
FMFileManagerException
-
readWrite
protected void readWrite(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position, boolean is_read) throws FMFileManagerException - Throws:
FMFileManagerException
-
read
public void read(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position) throws FMFileManagerException - Specified by:
read
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
write
public void write(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position) throws FMFileManagerException - Specified by:
write
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
flush
- Specified by:
flush
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
isPieceCompleteProcessingNeeded
public boolean isPieceCompleteProcessingNeeded(int piece_number) - Specified by:
isPieceCompleteProcessingNeeded
in interfaceFMFileAccess
-
setPieceComplete
public void setPieceComplete(FMFileAccess.FileAccessor fa, int piece_number, DirectByteBuffer piece_data) throws FMFileManagerException - Specified by:
setPieceComplete
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
getPieceIndex
protected int getPieceIndex(FMFileAccess.FileAccessor fa, int piece_number, boolean allocate_if_needed) throws FMFileManagerException - Throws:
FMFileManagerException
-
readConfig
- Throws:
FMFileManagerException
-
configBorked
- Throws:
FMFileManagerException
-
setDirty
- Throws:
FMFileManagerException
-
encodeConfig
private static Map encodeConfig(int storage_type, long current_length, long next_piece_index, int[] piece_map) -
recoverConfig
protected static void recoverConfig(TOTorrentFile torrent_file, File data_file, File config_file, int storage_type) throws FMFileManagerException - Throws:
FMFileManagerException
-
writeConfig
- Throws:
FMFileManagerException
-
getFile
- Specified by:
getFile
in interfaceFMFileAccess
-
getString
- Specified by:
getString
in interfaceFMFileAccess
-