4
<section id="state"><title>State</title>
6
<section id="closed"><title>Closed</title>
9
This is the initial state of a download. When switching to this mode,
10
all tracker requests are closed and the bitfield of completed chunks
11
is cleared. File paths can only be changed in this state. Functions
12
for getting information on bitfields, chunk count and various others
13
will return size 0 in this state. (TODO: Check which)
19
torrent::Download::is_open() == false;
20
torrent::Download::is_active() == false;
21
torrent::Download::is_tracker_busy() == false;
28
<section id="open"> <title>Open</title>
31
This is the state after a successfull call to
32
torrent::Download::open(). This function throws torrent::local_error
33
if the download could not be opened. All files in the download have
34
been created and are open. The initial hash check must be done to get
35
a valid bitfield of completed chunks.
41
torrent::Download::is_open() == true;
42
torrent::Download::is_active() == false;
49
<section id="active"> <title>Active</title>
52
A download is active after calling torrent::Download::start(). Only
53
downloads that are in an open state and has a valid bitfield of
54
completed chunks can be activated.
60
torrent::Download::is_open() == true;
61
torrent::Download::is_active() == true;
62
torrent::Download::is_hash_checked() == true;
68
A tracker request will be made when torrent::Download::stop() is
69
called on an active download. It is not required to wait for the
70
tracker request to finish before calling torrent::Download::close(),
71
but it is recommened so the tracker knows this client is not available.
78
<section id="file-paths">
79
<title>File Paths</title>
82
The paths of files in a Download consists of two parts, the
83
root directory and the paths of each file. The file paths are read
84
from the torrent file and the files usually reside in the root
85
directory. The root directory is by default "./" for single file
86
torrents and "./[torrent_name]/" for multi-file torrents.
93
// Get and set the root directory.
94
std::string torrent::Download::get_root_dir();
95
void torrent::Download::set_root_dir(const std::string& dir);
97
// Get the torrent::Entry class for each file in the download.
98
torrent::Entry torrent::Download::get_entry(uint32_t index);
99
uint32_t torrent::Download::get_entry_size();
101
typedef std::list<std::string> torrent::Entry::Path;
103
// Get and set the file path.
104
std::string torrent::Entry::get_path();
105
const Path& torrent::Entry::get_path_list();
107
void torrent::Entry::set_path_list(const Path& l);
114
The modifications can only be done while the download is in a
115
closed state. Modifying the file paths will not change the "info hash"
116
part of the bencode'd torrent associated with the download. (TODO:
117
When exporting, save root directory and file paths to another section
b'\\ No newline at end of file'