public final class TorrentHandle
extends java.lang.Object
.. warning:: Any member function that returns a value or fills in a value has to be made synchronously. This means it has to wait for the main thread to complete the query before it can return. This might potentially be expensive if done from within a GUI thread that needs to stay responsive. Try to avoid querying for information you don't need, and try to do it in as few calls as possible. You can get most of the interesting information about a torrent from the torrent_handle::status() call.
The default constructor will initialize the handle to an invalid state. Which means you cannot perform any operation on it, unless you first assign it a valid handle. If you try to perform any operation on an uninitialized handle, it will throw ``invalid_handle``.
.. warning:: All operations on a torrent_handle may throw libtorrent_exception exception, in case the handle is no longer referring to a torrent. There is one exception is_valid() will never throw. Since the torrents are processed by a background thread, there is no guarantee that a handle will remain valid between two calls.
Modifier and Type | Class and Description |
---|---|
static class |
TorrentHandle.FileProgressFlags
Flags to be passed in
fileProgress(TorrentHandle.FileProgressFlags) . |
Modifier and Type | Field and Description |
---|---|
static deadline_flags_t |
ALERT_WHEN_AVAILABLE |
static resume_data_flags_t |
FLUSH_DISK_CACHE
The disk cache will be flushed before creating the resume data.
|
static resume_data_flags_t |
ONLY_IF_MODIFIED
If nothing significant has changed in the torrent since the last
time resume data was saved, fail this attempt.
|
static add_piece_flags_t |
OVERWRITE_EXISTING
Instruct libtorrent to overwrite any data that may already have been
downloaded with the data of the new piece being added.
|
static status_flags_t |
QUERY_ACCURATE_DOWNLOAD_COUNTERS
includes partial downloaded blocks in ``total_done`` and
``total_wanted_done``.
|
static status_flags_t |
QUERY_DISTRIBUTED_COPIES
calculates ``distributed_copies``, ``distributed_full_copies`` and
``distributed_fraction``.
|
static status_flags_t |
QUERY_LAST_SEEN_COMPLETE
includes ``last_seen_complete``.
|
static status_flags_t |
QUERY_NAME
includes
name , the name of the torrent. |
static status_flags_t |
QUERY_PIECES
includes ``pieces``.
|
static status_flags_t |
QUERY_SAVE_PATH
includes ``save_path``, the path to the directory the files of the
torrent are saved to.
|
static status_flags_t |
QUERY_TORRENT_FILE
includes ``torrent_file``, which is all the static information from the .torrent file.
|
static status_flags_t |
QUERY_VERIFIED_PIECES
includes ``verified_pieces`` (only applies to torrents in *seed mode*).
|
static resume_data_flags_t |
SAVE_INFO_DICT
The resume data will contain the metadata from the torrent file as
well.
|
Constructor and Description |
---|
TorrentHandle(torrent_handle th) |
Modifier and Type | Method and Description |
---|---|
void |
addHttpSeed(java.lang.String url) |
void |
addPiece(int piece,
byte[] data)
Same as calling
addPiece(int, byte[], add_piece_flags_t) with
flags with value 0. |
void |
addPiece(int piece,
byte[] data,
add_piece_flags_t flags)
This function will write
data to the storage as piece piece ,
as if it had been downloaded from a peer. |
void |
addTracker(AnnounceEntry tracker)
This method will look if the specified tracker is already in the
set.
|
void |
addUrlSeed(java.lang.String url) |
void |
clearPieceDeadlines()
Removes deadlines on all pieces in the torrent.
|
Priority[] |
filePriorities()
Returns a vector with the priorities of all files.
|
Priority |
filePriority(int index)
index must be in the range [0, number_of_files).
|
void |
filePriority(int index,
Priority priority)
index must be in the range [0, number_of_files).
|
long[] |
fileProgress()
This function fills in the supplied vector with the number of
bytes downloaded of each file in this torrent.
|
long[] |
fileProgress(TorrentHandle.FileProgressFlags flags)
This function fills in the supplied vector with the number of
bytes downloaded of each file in this torrent.
|
torrent_flags_t |
flags() |
void |
flushCache()
Instructs libtorrent to flush all the disk caches for this torrent and
close all file handles.
|
void |
forceDHTAnnounce()
Announce the torrent to the DHT immediately.
|
void |
forceReannounce()
Force this torrent to do another tracker
request, to receive new peers.
|
void |
forceReannounce(int seconds) |
void |
forceReannounce(int seconds,
int tracker_index) |
void |
forceRecheck()
This method puts the torrent back in a state where it assumes to
have no resume data.
|
int |
getDownloadLimit() |
java.util.ArrayList<PartialPieceInfo> |
getDownloadQueue()
Returns an array (list) with information about pieces that are partially
downloaded or not downloaded at all but partially requested.
|
int[] |
getPieceAvailability() |
int |
getUploadLimit() |
boolean |
havePiece(int piece)
Returns true if this piece has been completely downloaded, and false
otherwise.
|
java.util.List<java.lang.String> |
httpSeeds()
Return a set of the url seeds currently in this
torrent.
|
Sha1Hash |
infoHash()
Returns the info-hash for the torrent.
|
boolean |
isValid()
Returns true if this handle refers to a valid torrent and false if it
hasn't been initialized or if the torrent it refers to has been
aborted.
|
java.lang.String |
makeMagnetUri()
Generates a magnet URI from the specified torrent.
|
void |
moveStorage(java.lang.String savePath)
Sames as calling
moveStorage(String, MoveFlags) with empty flags. |
void |
moveStorage(java.lang.String savePath,
MoveFlags flags)
Moves the file(s) that this torrent are currently seeding from or
downloading to.
|
java.lang.String |
name()
The name of the torrent.
|
boolean |
needSaveResumeData()
This function returns true if any whole chunk has been downloaded
since the torrent was first loaded or since the last time the resume
data was saved.
|
void |
pause()
This method will disconnect all peers.
|
java.util.ArrayList<PeerInfo> |
peerInfo()
Returns a list filled with one entry for each peer connected to this
torrent, given the handle is valid.
|
Priority[] |
piecePriorities() |
Priority |
piecePriority(int index) |
void |
piecePriority(int index,
Priority priority) |
void |
prioritizeFiles(Priority[] priorities)
Takes a vector that has at as many elements as
there are files in the torrent.
|
void |
prioritizePieces(Priority[] priorities) |
int |
queuePosition()
Every torrent that is added is assigned a queue position exactly one
greater than the greatest queue position of all existing torrents.
|
void |
queuePositionBottom()
The
queue_position_*() functions adjust the torrents position in
the queue. |
void |
queuePositionDown()
The
queue_position_*() functions adjust the torrents position in
the queue. |
void |
queuePositionSet(int position)
Updates the position in the queue for this torrent.
|
void |
queuePositionTop()
The
queue_position_*() functions adjust the torrents position in
the queue. |
void |
queuePositionUp()
The
queue_position_*() functions adjust the torrents position in
the queue. |
void |
readPiece(int piece)
This function starts an asynchronous read operation of the specified
piece from this torrent.
|
void |
removeHttpSeed(java.lang.String url) |
void |
removeUrlSeed(java.lang.String url) |
void |
renameFile(int index,
java.lang.String newName)
Renames the file with the given index asynchronously.
|
void |
replaceTrackers(java.util.List<AnnounceEntry> trackers)
If you want libtorrent to use another list of trackers for this torrent,
you can use
replaceTrackers(List) which takes a list of the same
form as the one returned from trackers() and will replace it. |
void |
resetPieceDeadline(int index)
Removes the deadline from the piece.
|
void |
resume()
Will reconnect all peers.
|
java.lang.String |
savePath()
The path to the directory where this torrent's files are stored.
|
void |
saveResumeData()
Similar to calling
saveResumeData(resume_data_flags_t) with
empty flags. |
void |
saveResumeData(resume_data_flags_t flags)
``save_resume_data()`` generates fast-resume data and returns it as an
entry.
|
void |
scrapeTracker()
Will send a scrape request to the tracker.
|
void |
setDownloadLimit(int limit) |
void |
setFlags(torrent_flags_t flags) |
void |
setFlags(torrent_flags_t flags,
torrent_flags_t mask) |
void |
setPieceDeadline(int index,
int deadline)
This function sets or resets the deadline associated with a specific
piece index (``index``).
|
void |
setPieceDeadline(int index,
int deadline,
deadline_flags_t flags)
This function sets or resets the deadline associated with a specific
piece index (``index``).
|
void |
setSslCertificate(java.lang.String certificate,
java.lang.String privateKey,
java.lang.String dhParams)
For SSL torrents, use this to specify a path to a .pem file to use as
this client's certificate.
|
void |
setSslCertificate(java.lang.String certificate,
java.lang.String privateKey,
java.lang.String dhParams,
java.lang.String passphrase)
For SSL torrents, use this to specify a path to a .pem file to use as
this client's certificate.
|
void |
setUploadLimit(int limit) |
TorrentStatus |
status()
Returns a structure with information about the status
of this torrent.
|
TorrentStatus |
status(boolean force)
`status()`` will return a structure with information about the status
of this torrent.
|
TorrentStatus |
status(status_flags_t flags)
This method returns an up to date torrent status, the
flags parameters
is an or-combination of the status_flags_t native values, in case you want
advanced (and expensive) fields filled. |
torrent_handle |
swig() |
TorrentInfo |
torrentFile()
Returns a pointer to the torrent_info object associated with this
torrent.
|
java.util.List<AnnounceEntry> |
trackers()
Will return a sorted list with the trackers of this torrent.
|
void |
unsetFlags(torrent_flags_t flags) |
java.util.List<java.lang.String> |
urlSeeds()
Return a set of the url seeds currently in this
torrent.
|
public static final add_piece_flags_t OVERWRITE_EXISTING
public static final status_flags_t QUERY_DISTRIBUTED_COPIES
public static final status_flags_t QUERY_ACCURATE_DOWNLOAD_COUNTERS
public static final status_flags_t QUERY_LAST_SEEN_COMPLETE
public static final status_flags_t QUERY_PIECES
public static final status_flags_t QUERY_VERIFIED_PIECES
public static final status_flags_t QUERY_TORRENT_FILE
public static final status_flags_t QUERY_NAME
name
, the name of the torrent. This is either derived
from the .torrent file, or from the &dn=
magnet link argument
or possibly some other source. If the name of the torrent is not
known, this is an empty string.public static final status_flags_t QUERY_SAVE_PATH
public static final resume_data_flags_t FLUSH_DISK_CACHE
public static final resume_data_flags_t SAVE_INFO_DICT
public static final resume_data_flags_t ONLY_IF_MODIFIED
public static final deadline_flags_t ALERT_WHEN_AVAILABLE
public TorrentHandle(torrent_handle th)
public torrent_handle swig()
public void addPiece(int piece, byte[] data, add_piece_flags_t flags)
data
to the storage as piece piece
,
as if it had been downloaded from a peer. data
is expected to
point to a buffer of as many bytes as the size of the specified piece.
The data in the buffer is copied and passed on to the disk IO thread
to be written at a later point.
By default, data that's already been downloaded is not overwritten by this buffer. If you trust this data to be correct (and pass the piece hash check) you may pass the overwrite_existing flag. This will instruct libtorrent to overwrite any data that may already have been downloaded with this data.
Since the data is written asynchronously, you may know that is passed
or failed the hash check by waiting for
PieceFinishedAlert
or
HashFailedAlert
.
piece
- the piece indexdata
- the piece dataflags
- flagspublic void addPiece(int piece, byte[] data)
addPiece(int, byte[], add_piece_flags_t)
with
flags
with value 0.piece
- the piece indexdata
- the piece datapublic void readPiece(int piece)
When the read operation is completed, it is passed back through an
alert, ReadPieceAlert
.
Since this alert is a response to an explicit
call, it will always be posted, regardless of the alert mask.
Note that if you read multiple pieces, the read operations are not guaranteed to finish in the same order as you initiated them.
piece
- the piece indexpublic boolean havePiece(int piece)
piece
- the piece indexpublic java.util.ArrayList<PeerInfo> peerInfo()
Each entry in the vector contains information about that particular peer.
PeerInfo
public TorrentInfo torrentFile()
TorrentInfo
object
may be a copy of the internal object.
If the torrent doesn't have metadata, the pointer will not be initialized (i.e. a NULL pointer). The torrent may be in a state without metadata only if it was started without a .torrent file, e.g. by using the libtorrent extension of just supplying a tracker and info-hash.
public TorrentStatus status(boolean force)
By default everything is included. The flags you can use to decide what to *include* are defined in the status_flags_t enum.
It is important not to call this method for each field in the status for performance reasons.
public TorrentStatus status()
public TorrentStatus status(status_flags_t flags)
flags
parameters
is an or-combination of the status_flags_t
native values, in case you want
advanced (and expensive) fields filled. We recommend the use of the simple call
to status()
that internally keep a cache with a small time resolution.flags
- the flagspublic java.util.ArrayList<PartialPieceInfo> getDownloadQueue()
PartialPieceInfo
for the fields in the returned vector.public Sha1Hash infoHash()
If this handle is to a torrent that hasn't loaded yet (for instance by being added) by a URL, the returned value is undefined.
public void pause()
When a torrent is paused, it will however
remember all share ratios to all peers and remember all potential (not
connected) peers. Torrents may be paused automatically if there is a
file error (e.g. disk full) or something similar. See
FileErrorAlert
.
To know if a torrent is paused or not, call
status()
and inspect TorrentStatus#isPaused() .
The ``flags`` argument to pause can be set to ``torrent_handle::graceful_pause`` which will delay the disconnect of peers that we're still downloading outstanding requests from. The torrent will not accept any more requests and will disconnect all idle peers. As soon as a peer is done transferring the blocks that were requested from it, it is disconnected. This is a graceful shut down of the torrent in the sense that no downloaded bytes are wasted.
torrents that are auto-managed may be automatically resumed again. It does not make sense to pause an auto-managed torrent without making it not automanaged first.
public void resume()
Torrents that are auto-managed may be automatically resumed again.
public torrent_flags_t flags()
public void setFlags(torrent_flags_t flags, torrent_flags_t mask)
public void setFlags(torrent_flags_t flags)
public void unsetFlags(torrent_flags_t flags)
public void flushCache()
CacheFlushedAlert
.
Note that by the time you get the alert, libtorrent may have cached
more data for the torrent, but you are guaranteed that whatever cached
data libtorrent had by the time you called
flushCache()
has been written to disk.
public boolean needSaveResumeData()
.. note:: A torrent's resume data is considered saved as soon as the alert is posted. It is important to make sure this alert is received and handled in order for this function to be meaningful.
public int queuePosition()
When a torrent is removed or turns into a seed, all torrents with greater queue positions have their positions decreased to fill in the space in the sequence.
This function returns the torrent's position in the download queue. The torrents with the smallest numbers are the ones that are being downloaded. The smaller number, the closer the torrent is to the front of the line to be started.
The queue position is also available in the torrent_status.
public void queuePositionUp()
queue_position_*()
functions adjust the torrents position in
the queue. Up means closer to the front and down means closer to the
back of the queue. Top and bottom refers to the front and the back of
the queue respectively.public void queuePositionDown()
queue_position_*()
functions adjust the torrents position in
the queue. Up means closer to the front and down means closer to the
back of the queue. Top and bottom refers to the front and the back of
the queue respectively.public void queuePositionTop()
queue_position_*()
functions adjust the torrents position in
the queue. Up means closer to the front and down means closer to the
back of the queue. Top and bottom refers to the front and the back of
the queue respectively.public void queuePositionBottom()
queue_position_*()
functions adjust the torrents position in
the queue. Up means closer to the front and down means closer to the
back of the queue. Top and bottom refers to the front and the back of
the queue respectively.public void queuePositionSet(int position)
position
- the new positionpublic void setSslCertificate(java.lang.String certificate, java.lang.String privateKey, java.lang.String dhParams)
Note that when a torrent first starts up, and it needs a certificate, it will suspend connecting to any peers until it has one. It's typically desirable to resume the torrent after setting the SSL certificate.
If you receive a TorrentNeedCertAlert
,
you need to call this to provide a valid cert. If you don't have a cert
you won't be allowed to connect to any peers.
certificate
- is a path to the (signed) certificate in .pem format
corresponding to this torrent.privateKey
- is a path to the private key for the specified
certificate. This must be in .pem format.dhParams
- is a path to the Diffie-Hellman parameter file, which
needs to be in .pem format. You can generate this file using the
openssl command like this: ``openssl dhparam -outform PEM -out
dhparams.pem 512``.public void setSslCertificate(java.lang.String certificate, java.lang.String privateKey, java.lang.String dhParams, java.lang.String passphrase)
Note that when a torrent first starts up, and it needs a certificate, it will suspend connecting to any peers until it has one. It's typically desirable to resume the torrent after setting the SSL certificate.
If you receive a TorrentNeedCertAlert
,
you need to call this to provide a valid cert. If you don't have a cert
you won't be allowed to connect to any peers.
certificate
- is a path to the (signed) certificate in .pem format
corresponding to this torrent.privateKey
- is a path to the private key for the specified
certificate. This must be in .pem format.dhParams
- is a path to the Diffie-Hellman parameter file, which
needs to be in .pem format. You can generate this file using the
openssl command like this: ``openssl dhparam -outform PEM -out
dhparams.pem 512``.passphrase
- may be specified if the private key is encrypted and
requires a passphrase to be decrypted.public void saveResumeData(resume_data_flags_t flags)
The ``flags`` argument is a bitmask of flags ORed together. see save_resume_flags_t
This operation is asynchronous, ``save_resume_data`` will return immediately. The resume data is delivered when it's done through an save_resume_data_alert.
The fast resume data will be empty in the following cases:
1. The torrent handle is invalid. 2. The torrent is checking (or is queued for checking) its storage, it will obviously not be ready to write resume data. 3. The torrent hasn't received valid metadata and was started without metadata (see libtorrent's metadata-from-peers_ extension)
Note that by the time you receive the fast resume data, it may already be invalid if the torrent is still downloading! The recommended practice is to first pause the session, then generate the fast resume data, and then close it down. Make sure to not remove_torrent() before you receive the save_resume_data_alert though. There's no need to pause when saving intermittent resume data.
.. warning:: If you pause every torrent individually instead of pausing the session, every torrent will have its paused state saved in the resume data!
.. warning:: The resume data contains the modification timestamps for all files. If one file has been modified when the torrent is added again, the will be rechecked. When shutting down, make sure to flush the disk cache before saving the resume data. This will make sure that the file timestamps are up to date and won't be modified after saving the resume data. The recommended way to do this is to pause the torrent, which will flush the cache and disconnect all peers.
.. note:: It is typically a good idea to save resume data whenever a torrent is completed or paused. In those cases you don't need to pause the torrent or the session, since the torrent will do no more writing to its files. If you save resume data for torrents when they are paused, you can accelerate the shutdown process by not saving resume data again for paused torrents. Completed torrents should have their resume data saved when they complete and on exit, since their statistics might be updated.
In full allocation mode the reume data is never invalidated by subsequent writes to the files, since pieces won't move around. This means that you don't need to pause before writing resume data in full or sparse mode. If you don't, however, any data written to disk after you saved resume data and before the session closed is lost.
It also means that if the resume data is out dated, libtorrent will not re-check the files, but assume that it is fairly recent. The assumption is that it's better to loose a little bit than to re-check the entire file.
It is still a good idea to save resume data periodically during download as well as when closing down.
Example code to pause and save resume data for all torrents and wait for the alerts:
.. code:: c++
extern int outstanding_resume_data; // global counter of outstanding resume data
std::vector<torrent_handle> handles = ses.get_torrents();
ses.pause();
for (std::vector<torrent_handle>::iterator i = handles.begin();
i != handles.end(); ++i)
{
torrent_handle& h = *i;
if (!h.is_valid()) continue;
torrent_status s = h.status();
if (!s.has_metadata) continue;
if (!s.need_save_resume_data()) continue;
h.save_resume_data();
++outstanding_resume_data;
}
while (outstanding_resume_data > 0)
{
alert const* a = ses.wait_for_alert(seconds(10));
// if we don't get an alert within 10 seconds, abort
if (a == 0) break;
std::auto_ptr<alert> holder = ses.pop_alert();
if (alert_cast<save_resume_data_failed_alert>(a))
{
process_alert(a);
--outstanding_resume_data;
continue;
}
save_resume_data_alert const* rd = alert_cast<save_resume_data_alert>(a);
if (rd == 0)
{
process_alert(a);
continue;
}
torrent_handle h = rd->handle;
torrent_status st = h.status(torrent_handle::query_save_path | torrent_handle::query_name);
std::ofstream out((st.save_path
+ "/" + st.name + ".fastresume").c_str()
, std::ios_base::binary);
out.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
--outstanding_resume_data;
}
.. note::
Note how ``outstanding_resume_data`` is a global counter in this
example. This is deliberate, otherwise there is a race condition for
torrents that was just asked to save their resume data, they posted
the alert, but it has not been received yet. Those torrents would
report that they don't need to save resume data again, and skipped by
the initial loop, and thwart the counter otherwise.public void saveResumeData()
saveResumeData(resume_data_flags_t)
with
empty flags.public boolean isValid()
public java.lang.String makeMagnetUri()
public int getUploadLimit()
public void setUploadLimit(int limit)
public int getDownloadLimit()
public void setDownloadLimit(int limit)
public void forceRecheck()
public void forceReannounce(int seconds, int tracker_index)
public void forceReannounce(int seconds)
public void forceReannounce()
If the tracker's ``min_interval`` has not passed since the last announce, the forced announce will be scheduled to happen immediately as the ``min_interval`` expires. This is to honor trackers minimum re-announce interval settings.
The ``tracker_index`` argument specifies which tracker to re-announce. If set to -1 (which is the default), all trackers are re-announce.
public void forceDHTAnnounce()
public java.util.List<AnnounceEntry> trackers()
The announce entry contains both a string url
which specify the
announce url for the tracker as well as an int tier
, which
specifies the order in which this tracker is tried.
public void scrapeTracker()
This request will specifically update the ``num_complete`` and ``num_incomplete`` fields in the torrent_status struct once it completes. When it completes, it will generate a scrape_reply_alert. If it fails, it will generate a scrape_failed_alert.
public void replaceTrackers(java.util.List<AnnounceEntry> trackers)
replaceTrackers(List)
which takes a list of the same
form as the one returned from trackers()
and will replace it.
If you want an immediate effect, you have to call forceReannounce()
.
The updated set of trackers will be saved in the resume data, and when a torrent is started with resume data, the trackers from the resume data will replace the original ones.
trackers
- the list of trackersAnnounceEntry
public void addTracker(AnnounceEntry tracker)
AnnounceEntry
.
The updated set of trackers will be saved in the resume data, and when a torrent is started with resume data, the trackers from the resume data will replace the original ones.
public void addUrlSeed(java.lang.String url)
public void removeUrlSeed(java.lang.String url)
public java.util.List<java.lang.String> urlSeeds()
public void addHttpSeed(java.lang.String url)
public void removeHttpSeed(java.lang.String url)
public java.util.List<java.lang.String> httpSeeds()
public int[] getPieceAvailability()
public void piecePriority(int index, Priority priority)
public Priority piecePriority(int index)
public void prioritizePieces(Priority[] priorities)
public Priority[] piecePriorities()
public void filePriority(int index, Priority priority)
The priority values are the same as for piece_priority().
Whenever a file priority is changed, all other piece priorities are reset to match the file priorities. In order to maintain sepcial priorities for particular pieces, piece_priority() has to be called again for those pieces.
You cannot set the file priorities on a torrent that does not yet have metadata or a torrent that is a seed. ``file_priority(int, int)`` and prioritize_files() are both no-ops for such torrents.
index
- priority
- public Priority filePriority(int index)
queries or sets the priority of file index.
index
- public void prioritizeFiles(Priority[] priorities)
priorities
- the array of prioritiespublic Priority[] filePriorities()
public void setPieceDeadline(int index, int deadline)
If the piece is already downloaded when this call is made, nothing happens, unless the alert_when_available flag is set, in which case it will do the same thing as calling read_piece() for ``index``.
index
- deadline
- public void setPieceDeadline(int index, int deadline, deadline_flags_t flags)
The ``flags`` parameter can be used to ask libtorrent to send an alert once the piece has been downloaded, by passing alert_when_available. When set, the read_piece_alert alert will be delivered, with the piece data, when it's downloaded.
If the piece is already downloaded when this call is made, nothing happens, unless the alert_when_available flag is set, in which case it will do the same thing as calling read_piece() for ``index``.
index
- deadline
- flags
- public void resetPieceDeadline(int index)
index
- public void clearPieceDeadlines()
resetPieceDeadline(int)
was called on all pieces.public long[] fileProgress(TorrentHandle.FileProgressFlags flags)
The ``flags`` parameter can be used to specify the granularity of the file progress. If left at the default value of 0, the progress will be as accurate as possible, but also more expensive to calculate. If ``torrent_handle::piece_granularity`` is specified, the progress will be specified in piece granularity. i.e. only pieces that have been fully downloaded and passed the hash check count. When specifying piece granularity, the operation is a lot cheaper, since libtorrent already keeps track of this internally and no calculation is required.
flags
- public long[] fileProgress()
public java.lang.String savePath()
public java.lang.String name()
public void moveStorage(java.lang.String savePath, MoveFlags flags)
savePath
is not located on the same
drive as the original save path, the files will be copied to the new
drive and removed from their original location. This will block all
other disk IO, and other torrents download and upload rates may drop
while copying the file.
Since disk IO is performed in a separate thread, this operation is
also asynchronous. Once the operation completes, the
StorageMovedAlert
is generated,
with the new path as the message. If the move fails for some reason,
StorageMovedFailedAlert
generated instead, containing the error message.
The flags
argument determines the behavior of the copying/moving
of the files in the torrent.
Files that have been renamed to have absolute paths are not moved by this function. Keep in mind that files that don't belong to the torrent but are stored in the torrent's directory may be moved as well. This goes for files that have been renamed to absolute paths that still end up inside the save path.
savePath
- the new save pathflags
- the move behavior flagspublic void moveStorage(java.lang.String savePath)
moveStorage(String, MoveFlags)
with empty flags.savePath
- the new pathmoveStorage(String, MoveFlags)
public void renameFile(int index, java.lang.String newName)
FileRenamedAlert
or
FileRenameFailedAlert
is posted.index
- newName
-