libktorrent  2.1.1
Public Member Functions | List of all members
bt::SingleFileCache Class Reference

Cache for single file torrents. More...

#include <singlefilecache.h>

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

Public Member Functions

 SingleFileCache (Torrent &tor, const QString &tmpdir, const QString &datadir)
 
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
 
virtual JobmoveDataFiles (const QMap< TorrentFileInterface *, QString > &files)
 
JobmoveDataFiles (const QString &ndir) override
 
virtual JobmoveDataFiles (const QString &ndir)=0
 
virtual void moveDataFilesFinished (const QMap< TorrentFileInterface *, QString > &files, Job *job)
 
void moveDataFilesFinished (Job *job) override
 
virtual void moveDataFilesFinished (Job *job)=0
 
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)
 
virtual void downloadStatusChanged (TorrentFile *, bool)
 Does nothing, can be overridden to be alerted of download status changes of a TorrentFile.
 
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 ()
 
virtual JobmoveDataFiles (const QMap< TorrentFileInterface *, QString > &files)
 
virtual void moveDataFilesFinished (const QMap< TorrentFileInterface *, QString > &files, Job *job)
 

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 implements Cache for a single file torrent

Definition at line 54 of file singlefilecache.h.

Member Function Documentation

◆ changeOutputPath()

void bt::SingleFileCache::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::SingleFileCache::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::SingleFileCache::close ( )
overridevirtual

Close the cache file(s).

Implements bt::Cache.

◆ create()

void bt::SingleFileCache::create ( )
overridevirtual

Create all the data files to store the data.

Implements bt::Cache.

◆ deleteDataFiles()

Job* bt::SingleFileCache::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::SingleFileCache::diskUsage ( )
overridevirtual

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

Implements bt::Cache.

◆ getMountPoints()

bool bt::SingleFileCache::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::SingleFileCache::getOutputPath ( ) const
inlineoverridevirtual

Get the actual output path.

Returns
The output path

Implements bt::Cache.

Definition at line 72 of file singlefilecache.h.

◆ hasMissingFiles()

bool bt::SingleFileCache::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::SingleFileCache::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::SingleFileCache::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/3]

virtual Job* bt::Cache::moveDataFiles

Move some files to a new location

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

◆ moveDataFiles() [2/3]

Job* bt::SingleFileCache::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.

◆ moveDataFiles() [3/3]

virtual Job* bt::Cache::moveDataFiles

Move the data files to a new directory.

Parameters
ndirThe directory
Returns
The job doing the move

◆ moveDataFilesFinished() [1/3]

virtual void bt::Cache::moveDataFilesFinished

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

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

◆ moveDataFilesFinished() [2/3]

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

A move of a bunch of data files has finished

Parameters
jobThe job doing the move

Implements bt::Cache.

◆ moveDataFilesFinished() [3/3]

virtual void bt::Cache::moveDataFilesFinished

A move of a bunch of data files has finished

Parameters
jobThe job doing the move

◆ open()

void bt::SingleFileCache::open ( )
overridevirtual

Open the cache file(s)

Implements bt::Cache.

◆ preparePiece()

PieceData::Ptr bt::SingleFileCache::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::SingleFileCache::preparePreallocation ( PreallocationThread prealloc)
overridevirtual

Prepare disksapce preallocation

Parameters
preallocThe thread going to do the preallocation

Implements bt::Cache.

◆ saveFileMap()

void bt::SingleFileCache::saveFileMap ( )
overridevirtual

Save the file map of a torrent

Implements bt::Cache.

◆ savePiece()

void bt::SingleFileCache::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: