From b7a461d280d06749aeb14af1e8c17cbf3616055b Mon Sep 17 00:00:00 2001 From: James Haggerty Date: Tue, 1 Nov 2022 17:08:05 +1100 Subject: Make the TOTP face use the filesystem for secret storage (#95) * TOTP using filesystem * Filesystem: ability to read files line by line --- movement/filesystem.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'movement/filesystem.h') diff --git a/movement/filesystem.h b/movement/filesystem.h index b0fb7f58..3cd3d092 100644 --- a/movement/filesystem.h +++ b/movement/filesystem.h @@ -69,6 +69,17 @@ int32_t filesystem_get_file_size(char *filename); */ bool filesystem_read_file(char *filename, char *buf, int32_t length); +/** @brief Reads a line from a file into a buffer + * @param filename the file you wish to read + * @param buf A buffer of at least length + 1 bytes; the file will be read into this buffer, + * and the last byte (buf[length]) will be set to 0 as a null terminator. + * @param offset Pointer to an int representing the offset into the file. This will be updated + * to reflect the offset of the next line. + * @param length The maximum number of bytes to read + * @return true if the read was successful; false otherwise + */ +bool filesystem_read_line(char *filename, char *buf, int32_t *offset, int32_t length); + /** @brief Writes file to the filesystem * @param filename the file you wish to write * @param text The contents of the file @@ -77,6 +88,14 @@ bool filesystem_read_file(char *filename, char *buf, int32_t length); */ bool filesystem_write_file(char *filename, char *text, int32_t length); +/** @brief Appends text to file on the filesystem + * @param filename the file you wish to write + * @param text The contents to write + * @param length The number of bytes to write + * @return true if the write was successful; false otherwise + */ +bool filesystem_append_file(char *filename, char *text, int32_t length); + /** @brief Handles the interactive file browser when Movement is plugged in to USB. * @param line The command that the user typed into the serial console. */ -- cgit v1.2.3