mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-07 18:52:30 +00:00
c4d548bafd
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@294 e378c898-3ddf-0310-93e7-cc216c733640
46 lines
808 B
C++
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;
|
|
}
|
|
|
|
}
|