Keep track of a piece of the file.
More...
#include <chunk.h>
|
enum | Status { ON_DISK,
NOT_DOWNLOADED
} |
|
- Author
- Joris Guisson
Keeps track of a piece of the file. The Chunk has 3 possible states :
- MMAPPED : It is memory mapped
- BUFFERED : It is in a buffer in dynamically allocated memory (because the chunk is located in 2 or more separate files, so we cannot just set a pointer to a region of mmapped memory)
- ON_DISK : On disk
- NOT_DOWNLOADED : It hasn't been dowloaded yet, and there is no buffer allocated
Definition at line 45 of file chunk.h.
◆ checkHash()
bool bt::Chunk::checkHash |
( |
const SHA1Hash & |
h | ) |
|
Check wehter the chunk matches it's hash.
- Parameters
-
- Returns
- true if the data matches the hash
◆ getPiece()
PieceData::Ptr bt::Chunk::getPiece |
( |
Uint32 |
off, |
|
|
Uint32 |
len, |
|
|
bool |
read_only |
|
) |
| |
Get a pointer to the data of a piece. If it isn't loaded, it will be loaded.
- Parameters
-
off | Offset of the piece |
len | Length of the piece |
read_only | Is this for reading the piece or for writing |
- Returns
- Pointer to the PieceData
◆ readPiece()
bool bt::Chunk::readPiece |
( |
Uint32 |
off, |
|
|
Uint32 |
len, |
|
|
Uint8 * |
data |
|
) |
| |
Read a piece from the chunk
- Parameters
-
off | The offset of the chunk
|
len | The length of the chunk |
data | The data, should be big enough to hold len bytes |
◆ savePiece()
void bt::Chunk::savePiece |
( |
PieceData::Ptr |
piece | ) |
|
Save a piece
- Parameters
-
off | Offset of the piece |
len | Length of the piece |
◆ setStatus()
void bt::Chunk::setStatus |
( |
Status |
s | ) |
|
|
inline |
Set the chunks status
- Parameters
-
Definition at line 89 of file chunk.h.
The documentation for this class was generated from the following file: