b4c14b82d9
Signed-off-by: Chloe M. <chloe@mirocom.org>
25 lines
383 B
C
25 lines
383 B
C
/*
|
|
* Copyright (c) 2026, Chloe Moffett
|
|
* Provided under the BSD-3 clause
|
|
*/
|
|
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include "libremail/file.h"
|
|
|
|
int
|
|
try_mkdir(const char *path, mode_t mode)
|
|
{
|
|
if (path == NULL) {
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
|
|
if (access(path, F_OK) != 0) {
|
|
return mkdir(path, mode);
|
|
}
|
|
|
|
return 0;
|
|
}
|