Changeset 1022 for trunk/rtorrent/src/utils/directory.cc
- Timestamp:
- 12/23/07 14:12:23 (4 years ago)
- Files:
-
- 1 modified
-
trunk/rtorrent/src/utils/directory.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rtorrent/src/utils/directory.cc
r938 r1022 47 47 namespace utils { 48 48 49 // Keep this? 49 50 bool 50 51 Directory::is_valid() const { … … 58 59 } 59 60 61 // Update should take various flags and sort functors. 60 62 bool 61 63 Directory::update(bool hideDot) { … … 70 72 struct dirent* ent; 71 73 74 // Err... let us use getdirentries here instead. 72 75 while ((ent = readdir(d)) != NULL) { 76 // Don't construct it here, check the const char. 73 77 std::string de(ent->d_name); 74 78 75 if (!de.empty() && (!hideDot || de[0] != '.')) 76 Base::push_back(ent->d_name); 79 if (!de.empty() && (!hideDot || de[0] != '.')) { 80 iterator itr = base_type::insert(end(), value_type()); 81 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 } 77 87 } 78 88 79 89 closedir(d); 80 Base::sort(std::less<std::string>());90 std::sort(begin(), end()); 81 91 82 92 return true; 83 93 } 84 94 85 Directory::Base 95 std::vector<std::string> 86 96 Directory::make_list() { 87 Base l; 97 std::vector<std::string> l; 98 l.reserve(size()); 88 99 89 for ( Base::iterator itr = begin(); itr != end(); ++itr)90 l.push_back(m_path + *itr);100 for (iterator itr = begin(); itr != end(); ++itr) 101 l.push_back(m_path + itr->d_name); 91 102 92 103 return l;
