diff --git a/lib/filesystem.c b/lib/filesystem.c index 65d8e91..c714b10 100644 --- a/lib/filesystem.c +++ b/lib/filesystem.c @@ -27,6 +27,10 @@ int filesystem_write(string_t path, byte_t *file_content, off_t file_size) { return 0; } +bool filesystem_exists(string_t path) { + return access(path, F_OK) == 0; +} + 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 21c9990..94df9ab 100644 --- a/lib/filesystem.h +++ b/lib/filesystem.h @@ -37,6 +37,16 @@ int filesystem_read(string_t path, byte_t **file_content, off_t *file_size); */ int filesystem_write(string_t path, byte_t *file_content, off_t file_size); +/** + * @brief Check if a path exists. + * + * @param path + * @retval true if the path exists. + * @retval false if the path does not exist. + * @since v3.1.0 + */ +bool filesystem_exists(string_t path); + /** * @brief Get the mimetype of a file. *