1
1
mirror of https://github.com/theoludwig/libcproject.git synced 2024-11-09 14:51:30 +01:00
libcproject/lib/filesystem.h
Théo LUDWIG eb798a619a
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.
2023-06-25 15:20:07 +02:00

52 lines
977 B
C

#ifndef __FILESYSTEM__
#define __FILESYSTEM__
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "string.h"
/**
* @brief Read the content of a file.
*
* @param path
* @param file_content
* @param file_size
* @return int
* @retval -1 if the file does not exist or if there is an error.
* @retval 0 for success.
* @since v1.0.0
*/
int filesystem_read(char *path, uint8_t **file_content, off_t *file_size);
/**
* @brief Write the content to a file.
*
* @param path
* @param file_content
* @param file_size
* @return int
* @retval -1 if there is an error.
* @retval 0 for success.
* @since v1.0.0
*/
int filesystem_write(char *path, uint8_t *file_content, off_t file_size);
/**
* @brief Get the mimetype of a file.
*
* @param path
* @return char*
* @since v1.0.0
*/
char *filesystem_get_mimetype(char *path);
#endif