summaryrefslogtreecommitdiffstats
path: root/movement/filesystem.h
diff options
context:
space:
mode:
authorJames Haggerty <james@gruemail.com>2022-11-01 17:08:05 +1100
committerGitHub <noreply@github.com>2022-11-01 01:08:05 -0500
commitb7a461d280d06749aeb14af1e8c17cbf3616055b (patch)
tree899fb8f3b9aefbbbcddc969f0e6d04570adc7661 /movement/filesystem.h
parent54495d2d295675da636c60d864715ea36e8ebedd (diff)
downloadSensor-Watch-b7a461d280d06749aeb14af1e8c17cbf3616055b.tar.gz
Sensor-Watch-b7a461d280d06749aeb14af1e8c17cbf3616055b.tar.bz2
Sensor-Watch-b7a461d280d06749aeb14af1e8c17cbf3616055b.zip
Make the TOTP face use the filesystem for secret storage (#95)
* TOTP using filesystem * Filesystem: ability to read files line by line
Diffstat (limited to 'movement/filesystem.h')
-rw-r--r--movement/filesystem.h19
1 files changed, 19 insertions, 0 deletions
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.
*/