libremail: file: Add try_touch() function
The try_touch() function is responsible for attempting to create new files while optionally filling it with initial data Signed-off-by: Chloe M. <chloe@mirocom.org>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Chloe Moffett
|
||||
* Provided under the BSD-3 clause
|
||||
*/
|
||||
|
||||
#ifndef LIBREMAIL_COMMON_H
|
||||
#define LIBREMAIL_COMMON_H 1
|
||||
|
||||
/* Length of SHA256 hash in bytes */
|
||||
#define SHA256_N_BYTES 32
|
||||
|
||||
#endif /* !LIBREMAIL_COMMON_H */
|
||||
@@ -18,4 +18,16 @@
|
||||
*/
|
||||
int try_mkdir(const char *path, mode_t mode);
|
||||
|
||||
/*
|
||||
* Attempt to create a new file if it doesn't exist
|
||||
*
|
||||
* @path: Path to file to create
|
||||
* @mode: Desired mode to assign
|
||||
* @buf: Buffer of initial data (NULLable)
|
||||
* @len: Length of initial data
|
||||
*
|
||||
* Returns zero on success
|
||||
*/
|
||||
int try_touch(const char *path, mode_t mode, void *buf, size_t len);
|
||||
|
||||
#endif /* !LIBREMAIL_FILE_H */
|
||||
|
||||
Reference in New Issue
Block a user