Make the TOTP face use the filesystem for secret storage (#95)

* TOTP using filesystem

* Filesystem: ability to read files line by line
This commit is contained in:
James Haggerty
2022-11-01 17:08:05 +11:00
committed by GitHub
parent 54495d2d29
commit b7a461d280
8 changed files with 626 additions and 2 deletions

View File

@@ -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.
*/