based on reworked servercore.
This commit is contained in:
1 parent
50eb707f10
commit
db3e82a18e
1698 files changed
+41157
-797
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user