From 40141a1f30fcf68c8e8adaaae58f2eb445aa096b Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 17 Oct 2018 17:44:33 +0700 Subject: [PATCH] implement peek() using read and seek --- libraries/FileSystem/src/FileIO.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/FileSystem/src/FileIO.cpp b/libraries/FileSystem/src/FileIO.cpp index cf2c1df6..ae684960 100644 --- a/libraries/FileSystem/src/FileIO.cpp +++ b/libraries/FileSystem/src/FileIO.cpp @@ -92,7 +92,9 @@ int File::read (void *buf, uint16_t nbyte) int File::peek (void) { - + int ch = read(); + seek((position() > 0) ? (position() - 1) : 0); + return ch; } int File::available (void) @@ -148,7 +150,7 @@ bool File::isDirectory (void) File File::openNextFile (uint8_t mode) { - + return _fs->_f_openNextFile(_hdl, mode); } void File::rewindDirectory (void)