Working on sessions.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@291 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-02-19 21:45:36 +00:00
parent a5f23adc7b
commit 5b050b594b
8 changed files with 168 additions and 1 deletions
+34
View File
@@ -0,0 +1,34 @@
#include "config.h"
#include <algorithm>
#include <functional>
#include <stdexcept>
#include <dirent.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);
}
std::sort(begin(), end(), std::less<std::string>());
}
}