From dff2836bfcfad53c3a922a5356bada4bc194d849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Sun, 6 Aug 2023 12:14:13 +0200 Subject: [PATCH] feat: add filesystem_remove --- lib/filesystem.c | 4 ++++ lib/filesystem.h | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/filesystem.c b/lib/filesystem.c index c714b10..3b4a79d 100644 --- a/lib/filesystem.c +++ b/lib/filesystem.c @@ -31,6 +31,10 @@ bool filesystem_exists(string_t path) { return access(path, F_OK) == 0; } +int filesystem_remove(string_t path) { + return remove(path); +} + string_t filesystem_get_mimetype(string_t path) { if (string_ends_with(path, ".html")) { return "text/html"; diff --git a/lib/filesystem.h b/lib/filesystem.h index 94df9ab..8339571 100644 --- a/lib/filesystem.h +++ b/lib/filesystem.h @@ -47,6 +47,17 @@ int filesystem_write(string_t path, byte_t *file_content, off_t file_size); */ bool filesystem_exists(string_t path); +/** + * @brief Removes a path. + * + * @param path + * @return int + * @retval -1 if there is an error. + * @retval 0 for success. + * @since v3.1.0 + */ +int filesystem_remove(string_t path); + /** * @brief Get the mimetype of a file. *