diff --git a/src/core/download.cc b/src/core/download.cc index aea59490..cf6158b1 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -98,6 +98,10 @@ Download::Download(download_type d) : m_variables.insert("max_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_max), rak::mem_fn(&m_download, &download_type::set_peers_max))); m_variables.insert("max_uploads", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::uploads_max), rak::mem_fn(&m_download, &download_type::set_uploads_max))); + m_variables.insert("max_file_size", new utils::VariableValueSlot(rak::mem_fn(file_list(), &file_list_type::max_file_size), rak::mem_fn(file_list(), &file_list_type::set_max_file_size))); +// m_variables.insert("split_file_size", new utils::VariableValueSlot(rak::mem_fn(file_list(), &file_list_type::split_file_size), rak::mem_fn(file_list(), &file_list_type::set_split_file_size))); +// m_variables.insert("split_suffix", new utils::VariableStringSlot(rak::mem_fn(file_list(), &file_list_type::split_suffix), rak::mem_fn(file_list(), &file_list_type::set_split_suffix))); + m_variables.insert("up_rate", new utils::VariableValueSlot(rak::mem_fn(m_download.up_rate(), &torrent::Rate::rate), NULL)); m_variables.insert("up_total", new utils::VariableValueSlot(rak::mem_fn(m_download.up_rate(), &torrent::Rate::total), NULL)); m_variables.insert("down_rate", new utils::VariableValueSlot(rak::mem_fn(m_download.down_rate(), &torrent::Rate::rate), NULL)); diff --git a/src/core/download.h b/src/core/download.h index 843ce6b6..a42fae42 100644 --- a/src/core/download.h +++ b/src/core/download.h @@ -51,6 +51,7 @@ namespace core { class Download { public: typedef torrent::Download download_type; + typedef torrent::FileList file_list_type; typedef torrent::TrackerList tracker_list_type; typedef download_type::ConnectionType connection_type; typedef utils::VariableMap variable_map_type; @@ -85,8 +86,8 @@ public: download_type* download() { return &m_download; } const download_type* c_download() const { return &m_download; } - torrent::FileList* file_list() { return m_download.file_list(); } - const torrent::FileList* c_file_list() const { return m_download.file_list(); } + file_list_type* file_list() { return m_download.file_list(); } + const file_list_type* c_file_list() const { return m_download.file_list(); } torrent::Object* bencode() { return m_download.bencode(); } tracker_list_type* tracker_list() { return &m_trackerList; } diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index fc3d1224..535e4ac5 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -190,6 +190,15 @@ DownloadFactory::receive_success() { if (!control->variable()->get_value("use_udp_trackers")) download->enable_udp_trackers(false); + if (control->variable()->get_value("max_file_size") > 0) + download->variable()->set("max_file_size", control->variable()->get("max_file_size")); + +// if (control->variable()->get_value("split_file_size") >= 0) +// download->variable()->set("split_file_size", control->variable()->get("split_file_size")); + +// if (!control->variable()->get_string("split_suffix").empty()) +// download->variable()->set("split_suffix", control->variable()->get("split_suffix")); + if (!rtorrent->has_key_string("directory")) download->variable()->set("directory", m_variables.get("directory")); else diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index 450e0d8c..6d64de41 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -519,6 +519,10 @@ initialize_option_handler(Control* c) { rak::mem_fn(torrent::chunk_manager(), &torrent::ChunkManager::set_preload_required_rate), 0, (1 << 10))); + variables->insert("max_file_size", new utils::VariableValue(-1)); + variables->insert("split_file_size", new utils::VariableValue(-1)); + variables->insert("split_suffix", new utils::VariableAny("")); + variables->insert("port_range", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_port_range, c))); variables->insert("hash_read_ahead", new utils::VariableValueSlot(rak::ptr_fn(torrent::hash_read_ahead), rak::bind_ptr_fn(&apply_hash_read_ahead, c))); diff --git a/src/utils/variable_generic.cc b/src/utils/variable_generic.cc index 427691a0..d4b09651 100644 --- a/src/utils/variable_generic.cc +++ b/src/utils/variable_generic.cc @@ -54,9 +54,7 @@ VariableAny::set(const torrent::Object& arg) { void VariableValue::set(const torrent::Object& arg) { - uint64_t value; - const char* first; - char* last; + int64_t value; switch (arg.type()) { case torrent::Object::TYPE_NONE: @@ -68,11 +66,7 @@ VariableValue::set(const torrent::Object& arg) { break; case torrent::Object::TYPE_STRING: - first = arg.as_string().c_str(); - value = strtoll(first, &last, 0); - - if (last == first || *last != '\0') - throw torrent::input_error("Could not convert string to value."); + string_to_value_unit(arg.as_string().c_str(), &value, 0, 1); m_variable = value; break;