mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 05:02:31 +00:00
* Make DownloadStore::save(...) validate the new file by loading the
bencoded data. * Make it safe to remove torrents that are selected. * Delete the rtorrent and libtorrent sections when loading non-session torrents. * Added ^O to change a torrent's root dir, ^P to set a variable. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@628 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -129,21 +129,30 @@ VariableBencode::~VariableBencode() {
|
||||
|
||||
const torrent::Bencode&
|
||||
VariableBencode::get() {
|
||||
return m_bencode->get_key(m_key);
|
||||
if (m_root.empty())
|
||||
return m_bencode->get_key(m_key);
|
||||
else
|
||||
return m_bencode->get_key(m_root).get_key(m_key);
|
||||
}
|
||||
|
||||
void
|
||||
VariableBencode::set(const torrent::Bencode& arg) {
|
||||
// Consider removing if TYPE_NONE.
|
||||
torrent::Bencode* root;
|
||||
|
||||
if (m_root.empty())
|
||||
root = m_bencode;
|
||||
else
|
||||
root = &m_bencode->get_key(m_root);
|
||||
|
||||
switch (m_type) {
|
||||
case torrent::Bencode::TYPE_NONE:
|
||||
m_bencode->insert_key(m_key, arg);
|
||||
root->insert_key(m_key, arg);
|
||||
break;
|
||||
|
||||
case torrent::Bencode::TYPE_STRING:
|
||||
if (arg.get_type() == torrent::Bencode::TYPE_STRING)
|
||||
m_bencode->insert_key(m_key, arg);
|
||||
root->insert_key(m_key, arg);
|
||||
else
|
||||
throw torrent::input_error("VariableBencode could not convert to string.");
|
||||
|
||||
|
||||
@@ -91,8 +91,11 @@ class VariableBencode : public Variable {
|
||||
public:
|
||||
typedef torrent::Bencode::Type Type;
|
||||
|
||||
VariableBencode(torrent::Bencode* b, const std::string& key, Type t = torrent::Bencode::TYPE_NONE) :
|
||||
m_bencode(b), m_key(key), m_type(t) {}
|
||||
VariableBencode(torrent::Bencode* b,
|
||||
const std::string& root,
|
||||
const std::string& key,
|
||||
Type t = torrent::Bencode::TYPE_NONE) :
|
||||
m_bencode(b), m_root(root), m_key(key), m_type(t) {}
|
||||
virtual ~VariableBencode();
|
||||
|
||||
virtual const torrent::Bencode& get();
|
||||
@@ -100,6 +103,7 @@ public:
|
||||
|
||||
private:
|
||||
torrent::Bencode* m_bencode;
|
||||
std::string m_root;
|
||||
std::string m_key;
|
||||
Type m_type;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user