53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#ifndef __MailFileSystem_h__
|
|
# define __MailFileSystem_h__
|
|
|
|
# include <sys/types.h>
|
|
# include <sys/stat.h>
|
|
# include <unistd.h>
|
|
# include "EPoll.h"
|
|
# include "INotify.h"
|
|
|
|
namespace mail {
|
|
|
|
class MailFileSystem {
|
|
|
|
public:
|
|
MailFileSystem(std::string mailPath) : mailPath(mailPath) {}
|
|
|
|
bool ifMailBoxExists(std::string mailbox) {
|
|
if(stat(getMailBoxPath(mailbox).c_str(), &statbuf) != -1)
|
|
if(S_ISDIR(statbuf.st_mode))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
bool ifAliasExists(std::string alias) {
|
|
if(stat(getMailBoxPath(alias).c_str(), &statbuf) != -1)
|
|
if(S_ISREG(statbuf.st_mode))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
std::string getMailBoxPath(std::string mailbox) {
|
|
coreutils::PString email(mailbox);
|
|
email.split("@");
|
|
std::string path = mailPath + "/" + email[1].str() + "/" + email[0].str();
|
|
return path;
|
|
}
|
|
|
|
std::vector<std::string> getAliasMailboxes(std::string alias);
|
|
|
|
std::string getMailPath() {
|
|
return mailPath;
|
|
}
|
|
|
|
private:
|
|
std::string mailPath;
|
|
struct stat statbuf;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|