Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sd: implement readBytes #4931

Merged
merged 3 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libraries/SD/src/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ int File::read(void *buf, uint16_t nbyte) {
return 0;
}

size_t File::readBytes(char *buffer, size_t length) {
int result = read(buffer, (uint16_t)length);
return result < 0 ? 0 : (size_t)result;
}

int File::available() {
if (! _file) return 0;

Expand Down
1 change: 1 addition & 0 deletions libraries/SD/src/SD.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class File : public Stream {
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buf, size_t size);
virtual int read();
virtual size_t readBytes(char *buffer, size_t length);
virtual int peek();
virtual int available();
virtual void flush();
Expand Down