kget
bt::ChunkManager Class Reference
#include <chunkmanager.h>

Detailed Description
Manages all Chunk's and the cache file, where all the chunk's are stored. It also manages a separate index file, where the position of each piece in the cache file is stored.
The chunks are stored in the cache file in the correct order. Eliminating the need for a file reconstruction algorithm for single files.
Definition at line 60 of file chunkmanager.h.
Constructor & Destructor Documentation
| bt::ChunkManager::ChunkManager | ( | Torrent & | tor, | |
| const QString & | tmpdir, | |||
| const QString & | datadir, | |||
| bool | custom_output_name, | |||
| CacheFactory * | fac | |||
| ) |
Definition at line 48 of file chunkmanager.cpp.
| bt::ChunkManager::~ChunkManager | ( | ) | [virtual] |
Definition at line 130 of file chunkmanager.cpp.
Member Function Documentation
| Uint64 bt::ChunkManager::bytesExcluded | ( | ) | const |
Calculates the number of bytes which have been excluded.
- Returns:
- The number of bytes excluded
Definition at line 530 of file chunkmanager.cpp.
| Uint64 bt::ChunkManager::bytesLeft | ( | ) | const |
Calculates the number of bytes left for the tracker.
Does include excluded chunks (this should be used for the tracker).
- Returns:
- The number of bytes to download + the number of bytes excluded
Definition at line 471 of file chunkmanager.cpp.
| Uint64 bt::ChunkManager::bytesLeftToDownload | ( | ) | const |
| void bt::ChunkManager::changeDataDir | ( | const QString & | data_dir | ) |
| void bt::ChunkManager::changeOutputPath | ( | const QString & | output_path | ) |
Definition at line 154 of file chunkmanager.cpp.
| void bt::ChunkManager::checkMemoryUsage | ( | ) |
| Uint32 bt::ChunkManager::chunksDownloaded | ( | ) | const |
| Uint32 bt::ChunkManager::chunksExcluded | ( | ) | const |
Get the number of chunks which have been excluded.
- Returns:
- The number of excluded chunks
Definition at line 557 of file chunkmanager.cpp.
| Uint32 bt::ChunkManager::chunksLeft | ( | ) | const |
Calculates the number of chunks left to download.
Does not include excluded chunks.
- Returns:
- The number of chunks to download
Definition at line 507 of file chunkmanager.cpp.
| bool bt::ChunkManager::completed | ( | ) | const |
| void bt::ChunkManager::corrupted | ( | Uint32 | chunk | ) | [signal] |
A corrupted chunk has been found during uploading.
- Parameters:
-
chunk The chunk
| void bt::ChunkManager::createFiles | ( | bool | check_priority = false |
) |
Create the cache file, and index files.
- Parameters:
-
check_priority Check if priority of chunk matches that of files
- Exceptions:
-
Error When it can be created
Definition at line 235 of file chunkmanager.cpp.
| void bt::ChunkManager::dataChecked | ( | const BitSet & | ok_chunks | ) |
Data has been checked, and these chunks are OK.
The ChunkManager will update it's internal structures
- Parameters:
-
ok_chunks The ok_chunks
Definition at line 1029 of file chunkmanager.cpp.
| void bt::ChunkManager::debugPrintMemUsage | ( | ) |
| void bt::ChunkManager::deleteDataFiles | ( | ) |
| Uint64 bt::ChunkManager::diskUsage | ( | ) |
Get the current disk usage of all the files in this torrent.
Definition at line 1230 of file chunkmanager.cpp.
| void bt::ChunkManager::dndMissingFiles | ( | ) |
Make sure that a range will not be downloaded.
- Parameters:
-
from First chunk in range to Last chunk in range
Definition at line 604 of file chunkmanager.cpp.
Emitted when a range of chunks has been excluded.
- Parameters:
-
from First chunk in range to Last chunk in range
| const BitSet& bt::ChunkManager::getBitSet | ( | ) | const [inline] |
| Chunk * bt::ChunkManager::getChunk | ( | unsigned int | i | ) |
Get's the i'th Chunk.
- Parameters:
-
i The Chunk's index
- Returns:
- The Chunk, or 0 when i is out of bounds
Definition at line 268 of file chunkmanager.cpp.
| QString bt::ChunkManager::getDataDir | ( | ) | const |
| const BitSet& bt::ChunkManager::getExcludedBitSet | ( | ) | const [inline] |
| Uint32 bt::ChunkManager::getNumChunks | ( | ) | const [inline] |
| const BitSet& bt::ChunkManager::getOnlySeedBitSet | ( | ) | const [inline] |
| QString bt::ChunkManager::getOutputPath | ( | ) | const |
| const Torrent& bt::ChunkManager::getTorrent | ( | ) | const [inline] |
| Chunk * bt::ChunkManager::grabChunk | ( | unsigned int | i | ) |
Get's the i'th Chunk.
Makes sure that the Chunk's data is in memory. If the Chunk hasn't been downloaded yet 0 is returned. Whenever the Chunk needs to be uploaded, call this function. This changes the status to MMAPPED or BUFFERED.
- Parameters:
-
i The Chunk's index
- Returns:
- The Chunk, or 0 when i is out of bounds
Definition at line 302 of file chunkmanager.cpp.
| bool bt::ChunkManager::hasExistingFiles | ( | ) | const |
Test if the torrent has existing files, only works the first time a torrent is loaded.
Definition at line 1082 of file chunkmanager.cpp.
| bool bt::ChunkManager::hasMissingFiles | ( | QStringList & | sl | ) |
Test all files and see if they are not missing.
If so put them in a list
Definition at line 263 of file chunkmanager.cpp.
| bool bt::ChunkManager::haveAllChunks | ( | ) | const |
Check if we have all chunks, this is not the same as chunksLeft() == 0, it does not look at excluded chunks.
- Returns:
- true if all chunks have been downloaded
Definition at line 525 of file chunkmanager.cpp.
Make sure that a range will be downloaded.
Does the opposite of exclude.
- Parameters:
-
from First chunk in range to Last chunk in range
Definition at line 625 of file chunkmanager.cpp.
Emitted when a range of chunks has been included back.
- Parameters:
-
from First chunk in range to Last chunk in range
| void bt::ChunkManager::loadIndexFile | ( | ) |
Loads the index file.
- Exceptions:
-
Error When it can be loaded
Definition at line 179 of file chunkmanager.cpp.
| void bt::ChunkManager::markExistingFilesAsDownloaded | ( | ) |
| KJob * bt::ChunkManager::moveDataFiles | ( | const QMap< TorrentFileInterface *, QString > & | files | ) |
Move some data files to a new location.
- Parameters:
-
files Map of files and their new location
Definition at line 169 of file chunkmanager.cpp.
Move the data files of the torrent.
- Parameters:
-
ndir The new directory
Definition at line 159 of file chunkmanager.cpp.
| void bt::ChunkManager::moveDataFilesFinished | ( | const QMap< TorrentFileInterface *, QString > & | files, | |
| KJob * | job | |||
| ) |
A move of data files with the map has finished.
- Parameters:
-
files Map of files and their new location job The job doing the move
Definition at line 174 of file chunkmanager.cpp.
| void bt::ChunkManager::moveDataFilesFinished | ( | KJob * | job | ) |
A move of data files has finished.
- Parameters:
-
job The job doing the move
Definition at line 164 of file chunkmanager.cpp.
| Uint32 bt::ChunkManager::onlySeedChunks | ( | ) | const |
| void bt::ChunkManager::preallocateDiskSpace | ( | PreallocationThread * | prealloc | ) |
Preallocate diskspace for all files.
- Parameters:
-
prealloc The thread doing the preallocation
Definition at line 1024 of file chunkmanager.cpp.
| bool bt::ChunkManager::prepareChunk | ( | Chunk * | c, | |
| bool | always = false | |||
| ) |
Prepare a chunk for downloading.
- Parameters:
-
c The Chunk always Always do this, even if the chunk is not NOT_DOWNLOADED
- Returns:
- true if ok, false if the chunk is not NOT_DOWNLOADED
Definition at line 1011 of file chunkmanager.cpp.
| Uint32 bt::ChunkManager::previewChunkRangeSize | ( | ) | const |
Get the size in chunks of the preview range for a single file torrent.
Definition at line 1257 of file chunkmanager.cpp.
| Uint32 bt::ChunkManager::previewChunkRangeSize | ( | const TorrentFile & | tf | ) | const |
Get the size in chunks of the preview range of a file of the torrent.
Definition at line 1235 of file chunkmanager.cpp.
Make sure that a range will get priority over other chunks.
- Parameters:
-
from First chunk in range to Last chunk in range
Definition at line 572 of file chunkmanager.cpp.
| void bt::ChunkManager::recreateMissingFiles | ( | ) |
| void bt::ChunkManager::releaseChunk | ( | unsigned int | i | ) |
The upload is done, and the Chunk is no longer needed.
The Chunk's data might be cleared, if we are using up to much memory.
- Parameters:
-
i The Chunk's index
Definition at line 354 of file chunkmanager.cpp.
| void bt::ChunkManager::resetChunk | ( | unsigned int | i | ) |
Reset a chunk as if it were never downloaded.
- Parameters:
-
i The chunk
Definition at line 370 of file chunkmanager.cpp.
| void bt::ChunkManager::saveChunk | ( | unsigned int | i, | |
| bool | update_index = true | |||
| ) |
Save the i'th Chunk to the cache_file.
Also changes the Chunk's status to ON_DISK. The Chunk's data is immediately cleared.
- Parameters:
-
i The Chunk's index update_index Update the index or not
Definition at line 412 of file chunkmanager.cpp.
| static void bt::ChunkManager::setMaxChunkSizeForDataCheck | ( | Uint32 | mcs | ) | [inline, static] |
Set the maximum chunk size for a data check, 0 means there is no limit.
Definition at line 335 of file chunkmanager.h.
| static void bt::ChunkManager::setUploadDataCheckingEnabled | ( | bool | on | ) | [inline, static] |
| void bt::ChunkManager::start | ( | ) |
Open the necessary files when the download gets started.
Definition at line 276 of file chunkmanager.cpp.
| void bt::ChunkManager::stop | ( | ) |
| void bt::ChunkManager::updateStats | ( | ) | [signal] |
Emitted when chunks get excluded or included, so that the statistics can be updated.
The documentation for this class was generated from the following files:
KDE 4.2 API Reference