libremail+tools: Add mailbox_create() function

It is best to prefer mailbox_create() rather than try_mkdir() directly
as we'll be able to encapslate mailbox creation logic within it.

Signed-off-by: Chloe M. <chloe@mirocom.org>
This commit is contained in:
2026-05-03 15:49:05 -04:00
parent 0a69f7f4f4
commit 9ffcf336d7
3 changed files with 52 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2026, Chloe Moffett
* Provided under the BSD-3 clause
*/
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
#include <errno.h>
#include "libremail/mailbox.h"
int
mailbox_create(const char *path, mode_t mode)
{
int error;
if (path == NULL) {
errno = EINVAL;
return -1;
}
error = mkdir(path, mode);
if (error < 0) {
perror("mkdir");
return -1;
}
return 0;
}