Files
rtorrent/src/utils/directory.cc
T
rakshasa c4d548bafd Loads correctly formated torrents from session dir when starting.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@294 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-20 17:21:23 +00:00

46 lines
808 B
C++

#include "config.h"
#include <algorithm>
#include <functional>
#include <stdexcept>
#include <dirent.h>
#include "functional.h"
#include "directory.h"
namespace utils {
void
Directory::update() {
if (m_path.empty())
throw std::logic_error("Directory::update() tried to open an empty path");
DIR* d = opendir(m_path.c_str());
if (d == NULL)
throw std::runtime_error("Directory::update() could not open directory");
struct dirent* ent;
while ((ent = readdir(d)) != NULL) {
std::string de(ent->d_name);
if (de != "." && de != "..")
Base::push_back(ent->d_name);
}
Base::sort(std::less<std::string>());
}
Directory::Base
Directory::make_list() {
Base l;
for (Base::iterator itr = begin(); itr != end(); ++itr)
l.push_back(m_path + *itr);
return l;
}
}