Many additions and changes.

This commit is contained in:
barant committed 2019-09-13 10:29:36 -07:00
1 parent 50f6e972de
commit 08169b1c3d
30 files changed
+451 -63

No files matched your search

+20 -3
View File
@@ -10,21 +10,38 @@ namespace coreutils {
public:
Directory(std::string path) {
dir = opendir(path);
dir = opendir(path.c_str());
if(dir) {
struct dirent entry = readdir(dir);
struct dirent *entry = readdir(dir);
while(entry) {
directory.emplace(std::string(entry->d_name), entry);
entry = readdir(dir)
entry = readdir(dir);
}
}
if(directory.size() > 0)
cursor = directory.begin();
}
~Directory() {}
bool eod() {
return cursor == directory.end();
}
DirectoryEntry get() {
if(cursor == directory.end())
return NULL;
return cursor->second;
}
void next() {
++cursor;
}
private:
DIR *dir;
std::map<std::string, DirectoryEntry> directory;
std::map<std::string, DirectoryEntry>::iterator cursor;