Skip to content

Commit

Permalink
Bugfix fs read+speed improvements (#125)
Browse files Browse the repository at this point in the history
* Revert "Edited VFSFileImpl::read to use both read/fread (espressif#6456)"

This reverts commit 7b89b39.

* Added default file buffer size + function to change it by user

Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
  • Loading branch information
Jason2866 and P-R-O-C-H-Y authored Apr 12, 2022
1 parent fb3838a commit b319ed3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions libraries/FS/src/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ size_t File::size() const
return _p->size();
}

bool File::setBufferSize(size_t size)
{
if (!*this) {
return 0;
}

return _p->setBufferSize(size);
}

void File::close()
{
if (_p) {
Expand Down
1 change: 1 addition & 0 deletions libraries/FS/src/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class File : public Stream
}
size_t position() const;
size_t size() const;
bool setBufferSize(size_t size);
void close();
operator bool() const;
time_t getLastWrite();
Expand Down
1 change: 1 addition & 0 deletions libraries/FS/src/FSImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class FileImpl
virtual bool seek(uint32_t pos, SeekMode mode) = 0;
virtual size_t position() const = 0;
virtual size_t size() const = 0;
virtual bool setBufferSize(size_t size) = 0;
virtual void close() = 0;
virtual time_t getLastWrite() = 0;
virtual const char* path() const = 0;
Expand Down
3 changes: 2 additions & 1 deletion libraries/FS/src/vfs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ class VFSFileImpl : public FileImpl
bool seek(uint32_t pos, SeekMode mode) override;
size_t position() const override;
size_t size() const override;
bool setBufferSize(size_t size);
void close() override;
const char* path() const override;
const char* name() const override;
time_t getLastWrite() override;
time_t getLastWrite() override;
boolean isDirectory(void) override;
FileImplPtr openNextFile(const char* mode) override;
void rewindDirectory(void) override;
Expand Down

0 comments on commit b319ed3

Please sign in to comment.