62 lines
1.8 KiB
C
62 lines
1.8 KiB
C
/**
|
|
* @file llfs.h
|
|
* @brief Linked List Filesystem header (llfs)
|
|
* @author Lorenz C.
|
|
*/
|
|
|
|
#ifndef LLFS_H
|
|
#define LLFS_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @brief Representation of a file in the llfs filesystem
|
|
*/
|
|
typedef struct llfs_file {
|
|
const uint8_t* data; // Pointer to the file data (len bytes)
|
|
const char* name; // Null-terminated string with the filename
|
|
size_t len; // Length of the file data
|
|
} llfs_file_t;
|
|
|
|
/**
|
|
* @brief Internal representation of a file in the filesystem
|
|
* @warning This struct should only be used in the llfs_data.c file.
|
|
*/
|
|
struct llfs_data_file {
|
|
const uint8_t* data;
|
|
const char* name;
|
|
const size_t len;
|
|
const struct llfs_data_file* next;
|
|
};
|
|
|
|
/**
|
|
* @brief Get a list of files in the filesystem
|
|
* Get a list of all the files in the filesystem.
|
|
*
|
|
* Use the filter to filter out files with a filename that do not match the filter. (e.g. "*.txt" or "*.png|*.jpg") (not
|
|
* implemented yet) Multiple filters can be used by separating them with a pipe (|).
|
|
*
|
|
* The following members of the llfs_file_t struct are set: name, len and data. @ref llfs_file_t
|
|
*
|
|
* @todo Implement file filter
|
|
*
|
|
* @param[out] file_list A pointer to an array of llfs_file_t to store the files in @ref llfs_file_t
|
|
* @param[in] max_files The maximum number of files to return (size of file_list)
|
|
* @param[in] filter A string with file extensions to filter out. (e.g. "*.txt" or "*.png|*.jpg")
|
|
* @return The number of files returned
|
|
*/
|
|
size_t llfs_file_list(llfs_file_t* file_list, size_t max_files, char* filter);
|
|
|
|
/**
|
|
* @brief Open a file
|
|
* Get a file from the filesystem by name.
|
|
*
|
|
* @param[in] name The name of the file to open
|
|
* @return A pointer to a llfs_file_t with the file data @ref llfs_file_t
|
|
* NULL if the file does not exist
|
|
*/
|
|
llfs_file_t* llfs_file_open(const char* name);
|
|
|
|
#endif // LLFS_H
|