From eb798a619a6e633747f3a65fcbc1afe0a5e37975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Sun, 25 Jun 2023 14:31:39 +0200 Subject: [PATCH] fix: update `filesystem_read` and `filesystem_write` signatures BREAKING CHANGE: take a `uint8_t` for file_content instead of `char` It makes more sense to treat files as array of "bytes", not only characters/text files. --- lib/filesystem.c | 4 ++-- lib/filesystem.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/filesystem.c b/lib/filesystem.c index 362b852..8174e75 100644 --- a/lib/filesystem.c +++ b/lib/filesystem.c @@ -1,6 +1,6 @@ #include "filesystem.h" -int filesystem_read(char *path, char **file_content, off_t *file_size) { +int filesystem_read(char *path, uint8_t **file_content, off_t *file_size) { int file_descriptor = open(path, O_RDONLY); if (file_descriptor == -1) { return -1; @@ -15,7 +15,7 @@ int filesystem_read(char *path, char **file_content, off_t *file_size) { return 0; } -int filesystem_write(char *path, char *file_content, off_t file_size) { +int filesystem_write(char *path, uint8_t *file_content, off_t file_size) { int file_descriptor = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (file_descriptor == -1) { return -1; diff --git a/lib/filesystem.h b/lib/filesystem.h index 2f697b9..7d05747 100644 --- a/lib/filesystem.h +++ b/lib/filesystem.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,7 @@ * @retval 0 for success. * @since v1.0.0 */ -int filesystem_read(char *path, char **file_content, off_t *file_size); +int filesystem_read(char *path, uint8_t **file_content, off_t *file_size); /** * @brief Write the content to a file. @@ -36,7 +37,7 @@ int filesystem_read(char *path, char **file_content, off_t *file_size); * @retval 0 for success. * @since v1.0.0 */ -int filesystem_write(char *path, char *file_content, off_t file_size); +int filesystem_write(char *path, uint8_t *file_content, off_t file_size); /** * @brief Get the mimetype of a file.