43 lines
662 B
C++
43 lines
662 B
C++
#ifndef __DirectoryEntry_h__
|
|
# define __DirectoryEntry_h__
|
|
|
|
#include <dirent.h>
|
|
#include <string>
|
|
#include <string.h>
|
|
|
|
namespace coreutils {
|
|
|
|
class DirectoryEntry {
|
|
|
|
public:
|
|
DirectoryEntry(struct dirent *entry) {
|
|
memcpy(&this->entry, entry, sizeof(struct dirent));
|
|
}
|
|
|
|
~DirectoryEntry() {}
|
|
|
|
std::string getName() {
|
|
return std::string(entry.d_name);
|
|
}
|
|
|
|
unsigned char getType() {
|
|
return entry.d_type;
|
|
}
|
|
|
|
bool isFile() {
|
|
return entry.d_type == DT_REG;
|
|
}
|
|
|
|
bool isDirectory() {
|
|
return entry.d_type == DT_DIR;
|
|
}
|
|
|
|
private:
|
|
struct dirent entry;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|