Skip to content

Improved readString() for File #5445

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

Merged
merged 21 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cb66837
added new boards
apicquot Dec 1, 2018
7037119
corrected block size error
apicquot Dec 2, 2018
24632ae
added board to last commit working well
apicquot Dec 7, 2018
8859aed
override of readString for File class
apicquot Dec 7, 2018
f385b02
Merge branch 'master' of https://github.com/esp8266/Arduino into impr…
apicquot Dec 7, 2018
9ea5551
correct indent
apicquot Dec 7, 2018
dc6b44b
correct indent
apicquot Dec 7, 2018
4fa9527
good indent
apicquot Dec 7, 2018
d6088bb
stricter test for end of string
apicquot Dec 7, 2018
acb99bc
same implementation than Stream by replacing timeRead by read
apicquot Dec 7, 2018
e2852c9
Merge branch 'master' into improved_readString_file
apicquot Dec 25, 2018
4844ad0
Merge branch 'master' into improved_readString_file
earlephilhower Jan 25, 2019
d16c23c
reading file by block of 256
apicquot Jan 26, 2019
9ae9ca1
make sure there is an end of string
apicquot Jan 26, 2019
6ffb881
Merge branch 'improved_readString_file' of https://github.com/apicquo…
apicquot Jan 26, 2019
3250224
Merge branch 'master' into improved_readString_file
apicquot Jan 26, 2019
d81e55a
fixed bug for file size multiple of 256
apicquot Jan 30, 2019
a2e7c6b
Merge branch 'improved_readString_file' of https://github.com/apicquo…
apicquot Jan 30, 2019
823dacb
Merge branch 'master' into improved_readString_file
apicquot Jan 31, 2019
df88c56
Merge branch 'master' into improved_readString_file
earlephilhower Feb 1, 2019
8e13d17
Merge branch 'master' into improved_readString_file
devyte Feb 4, 2019
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
13 changes: 13 additions & 0 deletions cores/esp8266/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ const char* File::name() const {
return _p->name();
}

String File::readString()
{
String ret;
ret.reserve(size() - position());
int c = read();
while (c >= 0)
{
ret += (char) c;
c = read();
}
return ret;
}

File Dir::openFile(const char* mode) {
if (!_impl) {
return File();
Expand Down
3 changes: 2 additions & 1 deletion cores/esp8266/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class File : public Stream
void close();
operator bool() const;
const char* name() const;

String readString() override;

protected:
FileImplPtr _p;
};
Expand Down
2 changes: 1 addition & 1 deletion cores/esp8266/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Stream: public Print {
// returns the number of characters placed in the buffer (0 means no valid data found)

// Arduino String functions to be added here
String readString();
virtual String readString();
String readStringUntil(char terminator);

protected:
Expand Down