Changeset 1022 for trunk/rtorrent/src/input/path_input.cc
- Timestamp:
- 12/23/07 14:12:23 (4 years ago)
- Files:
-
- 1 modified
-
trunk/rtorrent/src/input/path_input.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rtorrent/src/input/path_input.cc
r938 r1022 39 39 #include <functional> 40 40 #include <rak/algorithm.h> 41 #include <rak/f ile_stat.h>41 #include <rak/functional.h> 42 42 #include <rak/path.h> 43 44 #include <sys/types.h> 45 #include <sys/dir.h> 43 46 44 47 #include "path_input.h" … … 69 72 70 73 struct _transform_filename { 71 _transform_filename(const std::string& base) : m_base(base) {} 72 73 void operator () (std::string& filename) { 74 rak::file_stat fs; 75 76 if (!fs.update(rak::path_expand(m_base + filename))) 77 return; 78 79 else if (fs.is_directory()) 80 filename += '/'; 74 void operator () (utils::directory_entry& entry) { 75 if (entry.d_type == DT_DIR) 76 entry.d_name += '/'; 81 77 } 82 83 const std::string& m_base;84 78 }; 85 79 … … 96 90 } 97 91 98 std::for_each(dir.begin(), dir.end(), _transform_filename( str().substr(0, dirEnd)));92 std::for_each(dir.begin(), dir.end(), _transform_filename()); 99 93 100 94 Range r = find_incomplete(dir, str().substr(dirEnd, get_pos())); … … 103 97 return; // Show some nice colors here. 104 98 105 std::string base = rak::make_base (r.first, r.second);99 std::string base = rak::make_base<std::string>(r.first, r.second, rak::const_mem_ref(&utils::directory_entry::d_name)); 106 100 107 101 // Clear the path after the cursor to make this code cleaner. It's … … 134 128 } 135 129 130 inline bool 131 find_complete_compare(const utils::directory_entry& complete, const std::string& base) { 132 return complete.d_name.compare(0, base.size(), base); 133 } 134 135 inline bool 136 find_complete_not_compare(const utils::directory_entry& complete, const std::string& base) { 137 return !complete.d_name.compare(0, base.size(), base); 138 } 139 136 140 PathInput::Range 137 141 PathInput::find_incomplete(utils::Directory& d, const std::string& f) { 138 142 Range r; 139 143 140 r.first = std::find_if(d.begin(), d.end(), std::bind2nd(rak::compare_base<std::string>(), f));141 r.second = std::find_if(r.first, d.end(), std::not1(std::bind2nd(rak::compare_base<std::string>(), f)));144 r.first = std::find_if(d.begin(), d.end(), rak::bind2nd(std::ptr_fun(&find_complete_not_compare), f)); 145 r.second = std::find_if(r.first, d.end(), rak::bind2nd(std::ptr_fun(&find_complete_compare), f)); 142 146 143 147 return r;
