From 682cfdc6dfd2bddcc3358afab14e888b78079fe8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 1 Apr 2022 11:23:54 +0200 Subject: [PATCH] Revert "Edited VFSFileImpl::read to use both read/fread (#6456)" This reverts commit 7b89b39e1087742ada6e8992159390f885c07919. --- libraries/FS/src/vfs_api.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/libraries/FS/src/vfs_api.cpp b/libraries/FS/src/vfs_api.cpp index 9e200a1500b..e43b4397452 100644 --- a/libraries/FS/src/vfs_api.cpp +++ b/libraries/FS/src/vfs_api.cpp @@ -13,12 +13,9 @@ // limitations under the License. #include "vfs_api.h" -#include using namespace fs; -#define READ_SIZE_SWITCH 128 //swithc to read func when read size > 128bytes - FileImplPtr VFSImpl::open(const char* fpath, const char* mode, const bool create) { if(!_mountpoint) { @@ -377,28 +374,7 @@ size_t VFSFileImpl::read(uint8_t* buf, size_t size) return 0; } - //ERASE BYTEBUFFER and use read when size > READ_SIZE_SWITCH always - if(size > READ_SIZE_SWITCH) - { - //check some data in buffer exists –> clear buffer and move pointer to deleted data - size_t bytesinbuf = __fpending(_f); - if (bytesinbuf && (bytesinbuf != 128)) //buffer lenght is 128 bytes - { - fpurge(_f); - lseek(fileno(_f),(-128+bytesinbuf),SEEK_CUR); - } - - int res = ::read(fileno(_f), buf, size); - if (res < 0) { - // an error occurred - return 0; - } - return res; - } - else - { - return fread(buf, 1, size, _f); - } + return fread(buf, 1, size, _f); } void VFSFileImpl::flush()