Skip to content

Commit

Permalink
f.setBufferSize(FS_BUFSIZE); for buffered file functions
Browse files Browse the repository at this point in the history
  • Loading branch information
troyhacks committed Jan 23, 2025
1 parent df55650 commit 46a2bed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wled00/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static bool bufferedFind(const char *target, bool fromStart = true) {

size_t index = 0;
byte buf[FS_BUFSIZE];
f.setBufferSize(FS_BUFSIZE);
if (fromStart) f.seek(0);

while (f.position() < f.size() -1) {
Expand Down Expand Up @@ -107,6 +108,7 @@ static bool bufferedFindSpace(size_t targetLen, bool fromStart = true) {

size_t index = 0; // better to use size_t instead if uint16_t
byte buf[FS_BUFSIZE];
f.setBufferSize(FS_BUFSIZE);
if (fromStart) f.seek(0);

while (f.position() < f.size() -1) {
Expand Down Expand Up @@ -150,6 +152,7 @@ static bool bufferedFindObjectEnd() {
uint16_t objDepth = 0; //num of '{' minus num of '}'. return once 0
//size_t start = f.position();
byte buf[FS_BUFSIZE];
f.setBufferSize(FS_BUFSIZE);

while (f.position() < f.size() -1) {
size_t bufsize = f.read(buf, FS_BUFSIZE); // better to use size_t instead of uint16_t
Expand All @@ -175,7 +178,7 @@ static void writeSpace(size_t l)
{
byte buf[FS_BUFSIZE];
memset(buf, ' ', FS_BUFSIZE);

f.setBufferSize(FS_BUFSIZE);
while (l > 0) {
size_t block = (l>FS_BUFSIZE) ? FS_BUFSIZE : l;
f.write(buf, block);
Expand Down

0 comments on commit 46a2bed

Please sign in to comment.