2023-01-05 19:28:05 +01:00
|
|
|
#ifndef __FILESYSTEM__
|
|
|
|
#define __FILESYSTEM__
|
|
|
|
|
2023-01-07 19:38:01 +01:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <errno.h>
|
2023-01-05 19:28:05 +01:00
|
|
|
#include <fcntl.h>
|
2023-01-07 19:38:01 +01:00
|
|
|
#include <pwd.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "string.h"
|
2023-06-25 15:07:34 +02:00
|
|
|
#include "types.h"
|
2023-06-25 14:34:33 +02:00
|
|
|
|
2023-01-05 19:28:05 +01:00
|
|
|
/**
|
|
|
|
* @brief Read the content of a file.
|
|
|
|
*
|
|
|
|
* @param path
|
|
|
|
* @param file_content
|
|
|
|
* @param file_size
|
2023-06-24 21:13:00 +02:00
|
|
|
* @retval -1 if the file does not exist or if there is an error.
|
|
|
|
* @retval 0 for success.
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
2023-06-25 15:03:04 +02:00
|
|
|
int filesystem_read(string_t path, byte_t **file_content, off_t *file_size);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Write the content to a file.
|
|
|
|
*
|
|
|
|
* @param path
|
|
|
|
* @param file_content
|
|
|
|
* @param file_size
|
2023-06-24 21:13:00 +02:00
|
|
|
* @retval -1 if there is an error.
|
|
|
|
* @retval 0 for success.
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
2023-06-25 15:03:04 +02:00
|
|
|
int filesystem_write(string_t path, byte_t *file_content, off_t file_size);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the mimetype of a file.
|
|
|
|
*
|
|
|
|
* @param path
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
2023-06-25 15:03:04 +02:00
|
|
|
string_t filesystem_get_mimetype(string_t path);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
|
|
|
#endif
|