libktorrent  2.2.0
Classes | Public Types | Public Member Functions | List of all members
bt::CacheFile Class Reference

#include <cachefile.h>

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

Public Types

enum  Mode { READ, WRITE, RW }
 
typedef QSharedPointer< CacheFilePtr
 

Public Member Functions

void changePath (const QString &npath)
 Change the path of the file.
 
void close ()
 
Uint64 diskUsage ()
 Get the number of bytes this cache file is taking up.
 
void * map (MMappeable *thing, Uint64 off, Uint32 size, Mode mode)
 
void open (const QString &path, Uint64 size)
 
void preallocate (PreallocationThread *prealloc)
 
void read (Uint8 *buf, Uint32 size, Uint64 off)
 
void unmap (void *ptr, Uint32 size)
 
void write (const Uint8 *buf, Uint32 size, Uint64 off)
 

Detailed Description

Author
Joris Guisson joris.nosp@m..gui.nosp@m.sson@.nosp@m.gmai.nosp@m.l.com

Used by Single and MultiFileCache to write to disk.

Definition at line 72 of file cachefile.h.

Member Function Documentation

◆ close()

void bt::CacheFile::close ( )

Close the file, everything will be unmapped.

Parameters
to_be_reopenedIndicates if the close is temporarely (i.e. it will be reopened)

◆ map()

void* bt::CacheFile::map ( MMappeable thing,
Uint64  off,
Uint32  size,
Mode  mode 
)

Map a part of the file into memory, will expand the file if it is to small, but will not go past the limit set in open.

Parameters
thingThe thing that wishes to map the mmapping
offOffset into the file
sizeSize of the region to map
modeHow the region will be mapped
Returns
A ptr to the mmaped region, or 0 if something goes wrong

◆ open()

void bt::CacheFile::open ( const QString &  path,
Uint64  size 
)

Open the file.

Parameters
pathPath of the file
sizeMax size of the file
Exceptions
Errorwhen something goes wrong

◆ preallocate()

void bt::CacheFile::preallocate ( PreallocationThread prealloc)

Preallocate disk space

◆ read()

void bt::CacheFile::read ( Uint8 *  buf,
Uint32  size,
Uint64  off 
)

Read from the file.

Parameters
bufBuffer to store data
sizeSize to read
offOffset to read from in file

◆ unmap()

void bt::CacheFile::unmap ( void *  ptr,
Uint32  size 
)

Unmap a previously mapped region.

Parameters
ptrPtr to the region
sizeSize of the region

◆ write()

void bt::CacheFile::write ( const Uint8 *  buf,
Uint32  size,
Uint64  off 
)

Write to the file.

Parameters
bufBuffer to write
sizeSize to read
offOffset to read from in file

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