Changeset 1023
- Timestamp:
- 12/29/07 23:43:05 (4 years ago)
- Location:
- trunk/rtorrent/src
- Files:
-
- 8 modified
-
command_network.cc (modified) (2 diffs)
-
core/download_factory.cc (modified) (1 diff)
-
core/download_store.cc (modified) (1 diff)
-
core/manager.cc (modified) (2 diffs)
-
input/path_input.cc (modified) (1 diff)
-
main.cc (modified) (2 diffs)
-
utils/directory.cc (modified) (3 diffs)
-
utils/directory.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rtorrent/src/command_network.cc
r1022 r1023 45 45 #include <torrent/tracker_list.h> 46 46 #include <torrent/torrent.h> 47 #include <torrent/rate.h> 47 48 48 49 #include "core/dht_manager.h" … … 320 321 ADD_COMMAND_VALUE_TRI_KB("upload_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_up_throttle_i64), rak::ptr_fun(&torrent::up_throttle)); 321 322 323 ADD_COMMAND_VOID("get_up_rate", rak::make_mem_fun(torrent::up_rate(), &torrent::Rate::rate)); 324 ADD_COMMAND_VOID("get_up_total", rak::make_mem_fun(torrent::up_rate(), &torrent::Rate::total)); 325 ADD_COMMAND_VOID("get_down_rate", rak::make_mem_fun(torrent::down_rate(), &torrent::Rate::rate)); 326 ADD_COMMAND_VOID("get_down_total", rak::make_mem_fun(torrent::down_rate(), &torrent::Rate::total)); 327 322 328 ADD_VARIABLE_VALUE("tracker_numwant", -1); 323 329 -
trunk/rtorrent/src/core/download_factory.cc
r1017 r1023 223 223 rpc::call_command("d.set_directory", m_variables["directory"], rpc::make_target(download)); 224 224 else 225 rpc::call_command("d.set_directory ", rtorrent->get_key("directory"), rpc::make_target(download));225 rpc::call_command("d.set_directory_base", rtorrent->get_key("directory"), rpc::make_target(download)); 226 226 227 227 if (!m_session && m_variables["tied_to_file"].as_value()) -
trunk/rtorrent/src/core/download_store.cc
r1022 r1023 158 158 return utils::Directory(); 159 159 160 utils::Directory d; 161 d.set_path(m_path); 160 utils::Directory d(m_path); 162 161 163 if (!d.update( ))162 if (!d.update(utils::Directory::update_hide_dot)) 164 163 throw torrent::storage_error("core::DownloadStore::update() could not open directory \"" + m_path + "\""); 165 164 -
trunk/rtorrent/src/core/manager.cc
r1022 r1023 460 460 // Only include filenames starting with '.' if the pattern 461 461 // starts with the same. 462 itr->update( r.pattern()[0] != '.');462 itr->update((r.pattern()[0] != '.') ? utils::Directory::update_hide_dot : 0); 463 463 itr->erase(std::remove_if(itr->begin(), itr->end(), rak::on(rak::mem_ref(&utils::directory_entry::d_name), std::not1(r))), itr->end()); 464 464 465 std::transform(itr->begin(), itr->end(), std::back_inserter(nextCache), rak::bind1st(std::ptr_fun(&path_expand_transform), itr-> get_path() + "/"));465 std::transform(itr->begin(), itr->end(), std::back_inserter(nextCache), rak::bind1st(std::ptr_fun(&path_expand_transform), itr->path() + "/")); 466 466 } 467 467 … … 470 470 } 471 471 472 std::transform(currentCache.begin(), currentCache.end(), std::back_inserter(*paths), std::mem_fun_ref(&utils::Directory:: get_path));472 std::transform(currentCache.begin(), currentCache.end(), std::back_inserter(*paths), std::mem_fun_ref(&utils::Directory::path)); 473 473 } 474 474 -
trunk/rtorrent/src/input/path_input.cc
r1022 r1023 84 84 utils::Directory dir(dirEnd != 0 ? str().substr(0, dirEnd) : "./"); 85 85 86 if (!dir.update( ) || dir.empty()) {86 if (!dir.update(utils::Directory::update_sort | utils::Directory::update_hide_dot) || dir.empty()) { 87 87 mark_dirty(); 88 88 -
trunk/rtorrent/src/main.cc
r1022 r1023 101 101 void 102 102 load_session_torrents(Control* c) { 103 // Load session torrents. 104 std::vector<std::string> l = c->core()->download_store()->get_formated_entries().make_list(); 105 106 for (std::vector<std::string>::iterator first = l.begin(), last = l.end(); first != last; ++first) { 103 utils::Directory entries = c->core()->download_store()->get_formated_entries(); 104 105 for (utils::Directory::const_iterator first = entries.begin(), last = entries.end(); first != last; ++first) { 106 // We don't really support session torrents that are links. These 107 // would be overwritten anyway on exit, and thus not really be 108 // useful. 109 if (!first->is_file()) 110 continue; 111 107 112 core::DownloadFactory* f = new core::DownloadFactory(c->core()); 108 113 … … 110 115 f->set_session(true); 111 116 f->slot_finished(sigc::bind(sigc::ptr_fun(&rak::call_delete_func<core::DownloadFactory>), f)); 112 f->load( *first);117 f->load(entries.path() + first->d_name); 113 118 f->commit(); 114 119 } -
trunk/rtorrent/src/utils/directory.cc
r1022 r1023 39 39 #include <algorithm> 40 40 #include <functional> 41 #include <stdexcept>42 41 #include <dirent.h> 43 42 #include <rak/path.h> 43 #include <torrent/exceptions.h> 44 44 45 45 #include "directory.h" … … 61 61 // Update should take various flags and sort functors. 62 62 bool 63 Directory::update( bool hideDot) {63 Directory::update(int flags) { 64 64 if (m_path.empty()) 65 throw std::logic_error("Directory::update() tried to open an empty path");65 throw torrent::input_error("Directory::update() tried to open an empty path."); 66 66 67 67 DIR* d = opendir(rak::path_expand(m_path).c_str()); … … 70 70 return false; 71 71 72 struct dirent* ent ;72 struct dirent* entry; 73 73 74 // Err... let us use getdirentries here instead. 75 while ((ent = readdir(d)) != NULL) { 76 // Don't construct it here, check the const char. 77 std::string de(ent->d_name); 74 while ((entry = readdir(d)) != NULL) { 75 if ((flags & update_hide_dot) && entry->d_name[0] == '.') 76 continue; 78 77 79 if (!de.empty() && (!hideDot || de[0] != '.')) { 80 iterator itr = base_type::insert(end(), value_type()); 78 iterator itr = base_type::insert(end(), value_type()); 81 79 82 itr->d_fileno = ent->d_fileno; 83 itr->d_reclen = ent->d_reclen; 84 itr->d_type = ent->d_type; 85 itr->d_name = de; 86 } 80 itr->d_fileno = entry->d_fileno; 81 itr->d_reclen = entry->d_reclen; 82 itr->d_type = entry->d_type; 83 itr->d_name = std::string(entry->d_name, entry->d_name + entry->d_namlen); 87 84 } 88 85 89 86 closedir(d); 90 std::sort(begin(), end()); 87 88 if (flags & update_sort) 89 std::sort(begin(), end()); 91 90 92 91 return true; 93 92 } 94 93 95 std::vector<std::string>96 Directory::make_list() {97 std::vector<std::string> l;98 l.reserve(size());99 100 for (iterator itr = begin(); itr != end(); ++itr)101 l.push_back(m_path + itr->d_name);102 103 return l;104 94 } 105 106 } -
trunk/rtorrent/src/utils/directory.h
r1022 r1023 44 44 45 45 struct directory_entry { 46 // Fix. 47 bool is_file() const { return true; } 48 46 49 // The name and types should match POSIX. 47 50 uint32_t d_fileno; … … 72 75 using base_type::erase; 73 76 77 static const uint32_t buffer_size = 64 * 1024; 78 79 static const int update_sort = 0x1; 80 static const int update_hide_dot = 0x2; 81 74 82 Directory() {} 75 83 Directory(const std::string& path) : m_path(path) {} … … 77 85 bool is_valid() const; 78 86 79 bool update(bool hideDot = true); 80 81 // Ergh... 82 const std::string& get_path() { return m_path; } 87 const std::string& path() { return m_path; } 83 88 void set_path(const std::string& path) { m_path = path; } 84 89 85 // Make a list with full path names. 86 // 87 // Fix the uses of this, real bad stuff. 88 std::vector<std::string> make_list(); 90 bool update(int flags); 89 91 90 92 private:
