based on reworked servercore.

This commit is contained in:
barant committed 2020-02-29 19:25:13 -08:00
1 parent 50eb707f10
commit db3e82a18e
1698 files changed
+41157 -797

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
#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