Advancing along here.
This commit is contained in:
1 parent
5bd9e9ca21
commit
c3c9530b4b
5 files changed
+39
-37
No files matched your search
+17
-17
@@ -5,46 +5,46 @@
|
||||
# include "DirectoryEntry.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
|
||||
class Directory {
|
||||
|
||||
|
||||
public:
|
||||
Directory(std::string path) {
|
||||
dir = opendir(path.c_str());
|
||||
if(dir) {
|
||||
struct dirent *entry = readdir(dir);
|
||||
while(entry) {
|
||||
directory.emplace(std::string(entry->d_name), entry);
|
||||
entry = readdir(dir);
|
||||
}
|
||||
dir = opendir(path.c_str());
|
||||
if(dir) {
|
||||
struct dirent *entry = readdir(dir);
|
||||
while(entry) {
|
||||
directory.emplace(std::string(entry->d_name), entry);
|
||||
entry = readdir(dir);
|
||||
}
|
||||
}
|
||||
if(directory.size() > 0)
|
||||
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;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user