Core Changes

This commit is contained in:
Matt Arant committed 2023-10-06 18:32:17 +00:00
1 parent 2a8cfcee2a
commit ac142b6a66
35 files changed
+6395 -423

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
#ifndef __Directory_h__
# define __Directory_h__
# include "includes"
# include "DirectoryEntry.h"
# include "Log.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);
}
}
if(directory.size() > 0)
cursor = directory.begin();
}
~Directory() {}
bool eod() {
return cursor == directory.end();
}
DirectoryEntry get() {
if(eod())
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