mirror of
https://github.com/theoludwig/libcproject.git
synced 2024-11-08 22:31:31 +01:00
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.
This commit is contained in:
parent
b9f573bfb2
commit
eb798a619a
@ -1,6 +1,6 @@
|
|||||||
#include "filesystem.h"
|
#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);
|
int file_descriptor = open(path, O_RDONLY);
|
||||||
if (file_descriptor == -1) {
|
if (file_descriptor == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -15,7 +15,7 @@ int filesystem_read(char *path, char **file_content, off_t *file_size) {
|
|||||||
return 0;
|
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);
|
int file_descriptor = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||||
if (file_descriptor == -1) {
|
if (file_descriptor == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -23,7 +24,7 @@
|
|||||||
* @retval 0 for success.
|
* @retval 0 for success.
|
||||||
* @since v1.0.0
|
* @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.
|
* @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.
|
* @retval 0 for success.
|
||||||
* @since v1.0.0
|
* @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.
|
* @brief Get the mimetype of a file.
|
||||||
|
Loading…
Reference in New Issue
Block a user