summaryrefslogtreecommitdiff
path: root/src/user/libcanyo/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/libcanyo/file.c')
-rw-r--r--src/user/libcanyo/file.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/user/libcanyo/file.c b/src/user/libcanyo/file.c
new file mode 100644
index 0000000..d314887
--- /dev/null
+++ b/src/user/libcanyo/file.c
@@ -0,0 +1,15 @@
+#include <stdint.h>
+#include <pland.h>
+
+//max_length and return value include null-terminator
+uint32_t read_line(fs_handle handle, uint32_t max_length, void *buffer) {
+ int index = 0;
+
+ while (++index < max_length) {
+ if (!fs_read(handle, 1, buffer + index - 1) || (*(uint8_t *)(buffer + index - 1) == '\n'))
+ break;
+ }
+
+ *(uint8_t *)(buffer + index - 1) = '\0';
+ return index;
+} \ No newline at end of file