libktorrent  2.2.0
Public Member Functions | List of all members
bt::MultiFileCache Class Reference

Cache for multi file torrents. More...

#include <multifilecache.h>

Inheritance diagram for bt::MultiFileCache:
Inheritance graph
[legend]

Public Member Functions

 MultiFileCache (Torrent &tor, const QString &tmpdir, const QString &datadir, bool custom_output_name)
 
void changeOutputPath (const QString &outputpath) override
 
void changeTmpDir (const QString &ndir) override
 
void close () override
 
void create () override
 
JobdeleteDataFiles () override
 
Uint64 diskUsage () override
 
bool getMountPoints (QSet< QString > &mps) override
 
QString getOutputPath () const override
 
bool hasMissingFiles (QStringList &sl) override
 
void loadFileMap () override
 
PieceData::Ptr loadPiece (Chunk *c, Uint32 off, Uint32 length) override
 
JobmoveDataFiles (const QMap< TorrentFileInterface *, QString > &files) override
 
JobmoveDataFiles (const QString &ndir) override
 
void moveDataFilesFinished (const QMap< TorrentFileInterface *, QString > &files, Job *job) override
 
void moveDataFilesFinished (Job *job) override
 
void open () override
 
PieceData::Ptr preparePiece (Chunk *c, Uint32 off, Uint32 length) override
 
void preparePreallocation (PreallocationThread *prealloc) override
 
void saveFileMap () override
 
void savePiece (PieceData::Ptr piece) override
 
- Public Member Functions inherited from bt::Cache
 Cache (Torrent &tor, const QString &tmpdir, const QString &datadir)
 
void checkMemoryUsage ()
 
void clearPieces (Chunk *c)
 
QString getDataDir () const
 Get the datadir.
 
bool hasExistingFiles () const
 See if the download has existing files.
 
bool isStorageMounted (QStringList &missing)
 Is the storage mounted ?
 
void loadMountPoints ()
 

Additional Inherited Members

- Static Public Member Functions inherited from bt::Cache
static bool mappedModeAllowed ()
 
static bool preallocateFully ()
 
static bool preallocationEnabled ()
 
static void setPreallocateFully (bool on)
 
static void setPreallocationEnabled (bool on)
 
- Protected Types inherited from bt::Cache
typedef QMultiMap< Chunk *, PieceData::Ptr > PieceCache
 
- Protected Member Functions inherited from bt::Cache
void cleanupPieceCache ()
 
void clearPieceCache ()
 
PieceData::Ptr findPiece (Chunk *c, Uint32 off, Uint32 len, bool read_only)
 
void insertPiece (Chunk *c, PieceData::Ptr p)
 
void saveMountPoints (const QSet< QString > &mp)
 
- Protected Attributes inherited from bt::Cache
QString datadir
 
Uint32 mmap_failures
 
QSet< QString > mount_points
 
PieceCache piece_cache
 
bool preexisting_files
 
QString tmpdir
 
Torrenttor
 

Detailed Description

Author
Joris Guisson

This class manages a multi file torrent cache. Everything gets stored in the correct files immediately.

Definition at line 39 of file multifilecache.h.

Member Function Documentation

◆ changeOutputPath()

void bt::MultiFileCache::changeOutputPath ( const QString &  outputpath)
overridevirtual

Changes output path. All data files should already been moved. This just modifies the datadir variable.

Parameters
outputpathNew output path

Implements bt::Cache.

◆ changeTmpDir()

void bt::MultiFileCache::changeTmpDir ( const QString &  ndir)
overridevirtual

Changes the tmp dir. All data files should already been moved. This just modifies the tmpdir variable.

Parameters
ndirThe new tmpdir

Reimplemented from bt::Cache.

◆ close()

void bt::MultiFileCache::close ( )
overridevirtual

Close the cache file(s).

Implements bt::Cache.

◆ create()

void bt::MultiFileCache::create ( )
overridevirtual

Create all the data files to store the data.

Implements bt::Cache.

◆ deleteDataFiles()

Job* bt::MultiFileCache::deleteDataFiles ( )
overridevirtual

Delete all data files, in case of multi file torrents empty directories should also be deleted.

Returns
The job doing the delete

Implements bt::Cache.

◆ diskUsage()

Uint64 bt::MultiFileCache::diskUsage ( )
overridevirtual

Get the number of bytes all the files of this torrent are currently using on disk.

Implements bt::Cache.

◆ getMountPoints()

bool bt::MultiFileCache::getMountPoints ( QSet< QString > &  mps)
overridevirtual

Determine the mount points of all the files in this torrent

Returns
bool True if we can, false if not

Implements bt::Cache.

◆ getOutputPath()

QString bt::MultiFileCache::getOutputPath ( ) const
overridevirtual

Get the actual output path.

Returns
The output path

Implements bt::Cache.

◆ hasMissingFiles()

bool bt::MultiFileCache::hasMissingFiles ( QStringList &  sl)
overridevirtual

Test all files and see if they are not missing. If so put them in a list

Implements bt::Cache.

◆ loadFileMap()

void bt::MultiFileCache::loadFileMap ( )
overridevirtual

Load the file map of a torrent. If it doesn't exist, it needs to be created.

Implements bt::Cache.

◆ loadPiece()

PieceData::Ptr bt::MultiFileCache::loadPiece ( Chunk c,
Uint32  off,
Uint32  length 
)
overridevirtual

Load a piece into memory. If something goes wrong, an Error should be thrown.

Parameters
cThe Chunk
offThe offset of the piece
lengthThe length of the piece
Returns
Pointer to the data

Implements bt::Cache.

◆ moveDataFiles() [1/2]

Job* bt::MultiFileCache::moveDataFiles ( const QMap< TorrentFileInterface *, QString > &  files)
overridevirtual

Move some files to a new location

Parameters
filesMap of files to move and their new location
Returns
Job The job doing the move

Reimplemented from bt::Cache.

◆ moveDataFiles() [2/2]

Job* bt::MultiFileCache::moveDataFiles ( const QString &  ndir)
overridevirtual

Move the data files to a new directory.

Parameters
ndirThe directory
Returns
The job doing the move

Implements bt::Cache.

◆ moveDataFilesFinished() [1/2]

void bt::MultiFileCache::moveDataFilesFinished ( const QMap< TorrentFileInterface *, QString > &  files,
Job job 
)
overridevirtual

The job doing moveDataFiles (with the map parameter) has finished

Parameters
filesThe files map with all the moves
jobThe job doing the move

Reimplemented from bt::Cache.

◆ moveDataFilesFinished() [2/2]

void bt::MultiFileCache::moveDataFilesFinished ( Job job)
overridevirtual

A move of a bunch of data files has finished

Parameters
jobThe job doing the move

Implements bt::Cache.

◆ open()

void bt::MultiFileCache::open ( )
overridevirtual

Open the cache file(s)

Implements bt::Cache.

◆ preparePiece()

PieceData::Ptr bt::MultiFileCache::preparePiece ( Chunk c,
Uint32  off,
Uint32  length 
)
overridevirtual

Prepare a piece for writing. If something goes wrong, an Error should be thrown.

Parameters
cThe Chunk
offThe offset of the piece
lengthThe length of the piece
Returns
Pointer to the data

Implements bt::Cache.

◆ preparePreallocation()

void bt::MultiFileCache::preparePreallocation ( PreallocationThread prealloc)
overridevirtual

Prepare disksapce preallocation

Parameters
preallocThe thread going to do the preallocation

Implements bt::Cache.

◆ saveFileMap()

void bt::MultiFileCache::saveFileMap ( )
overridevirtual

Save the file map of a torrent

Implements bt::Cache.

◆ savePiece()

void bt::MultiFileCache::savePiece ( PieceData::Ptr  piece)
overridevirtual

Save a piece to disk, will only actually save in buffered mode

Parameters
pieceThe piece

Implements bt::Cache.


The documentation for this class was generated from the following file: