Advancing along here.
This commit is contained in:
parent
5bd9e9ca21
commit
c3c9530b4b
34
Directory.h
34
Directory.h
@ -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
|
@ -4,25 +4,25 @@
|
||||
# include "includes"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
|
||||
class DirectoryEntry {
|
||||
|
||||
|
||||
public:
|
||||
DirectoryEntry(struct dirent *entry) {
|
||||
memcpy(&this->entry, entry, sizeof(struct dirent));
|
||||
memcpy(&this->entry, entry, sizeof(struct dirent));
|
||||
}
|
||||
|
||||
~DirectoryEntry() {}
|
||||
|
||||
|
||||
~DirectoryEntry() {}
|
||||
|
||||
std::string getName() {
|
||||
return std::string(entry.d_name);
|
||||
return std::string(entry.d_name);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
struct dirent entry;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
2
File.cpp
2
File.cpp
@ -23,7 +23,7 @@ namespace coreutils {
|
||||
}
|
||||
|
||||
File::~File() {
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void File::setBufferSize(size_t size) {
|
||||
|
18
File.h
18
File.h
@ -5,32 +5,32 @@
|
||||
|
||||
///
|
||||
/// File
|
||||
///
|
||||
///
|
||||
/// File abstraction class for accessing local file system files.
|
||||
///
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
|
||||
class File {
|
||||
|
||||
|
||||
public:
|
||||
File(std::string fileName, int mode = O_RDONLY, int authority = 0664);
|
||||
~File();
|
||||
~File();
|
||||
void setBufferSize(size_t size);
|
||||
void read();
|
||||
void write(std::string data);
|
||||
std::string asString();
|
||||
|
||||
|
||||
char *buffer;
|
||||
size_t size;
|
||||
|
||||
|
||||
std::string fileName;
|
||||
|
||||
|
||||
private:
|
||||
int fd;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -16,6 +16,8 @@ namespace coreutils {
|
||||
|
||||
bool IMFMessage::parse(PString &in) {
|
||||
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "Parsing-------\n" << in.str();
|
||||
|
||||
while (!in.ifNext("\r\n")) {
|
||||
headers.emplace_back(in);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user