From a9759e3bc2a424de37b61652f4dd0f46e8673d25 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Wed, 24 Aug 2022 01:36:55 +0200 Subject: [PATCH] lib/file: Clarify what the functions do, take cursor position into account for cut functions and add missing cut function --- src/lib/file.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/file.hpp b/src/lib/file.hpp index 44b3de5..6c08359 100644 --- a/src/lib/file.hpp +++ b/src/lib/file.hpp @@ -45,6 +45,7 @@ class File { void close(); // only applicable to read and edit modes + // moves the cursor to the right of the read section ErrorOr readByte(); ErrorOr> read(uint64_t bytes); // @SodaFountain (or whoever ends up implementing this): @@ -57,20 +58,24 @@ class File { // only applicable to write, modify, append, and edit modes // in modify and edit modes, overwrite whatever is at the // cursor position if there is anything there + // moves the cursor to the right of the written section ErrorOrVoid writeByte(uint8_t byte); ErrorOrVoid write(std::vector data); ErrorOrVoid writeString(tiny_utf8::string string); // only applicable to modify and edit modes // insert at cursor position and move other contents to the right + // moves the cursor to the right of the inserted section ErrorOrVoid insertByte(uint8_t byte); ErrorOrVoid insert(std::vector data); ErrorOrVoid insertString(tiny_utf8::string string); // only applicable to edit mode // return the cut section, remove cut section from file - ErrorOr> cut(uint64_t start, uint64_t end); - ErrorOr cutString(uint64_t start, uint64_t end); + // moves the cursor to the right of where it happened + ErrorOr cutByte(); + ErrorOr> cut(uint64_t length); + ErrorOr cutString(uint64_t length); // modes: // r (read)