FastLED 3.9.15
Loading...
Searching...
No Matches

◆ readText()

bool fl::FileSystem::readText ( const char * path,
fl::string * out )

Definition at line 171 of file file_system.cpp.

171 {
172 FileHandlePtr file = openRead(path);
173 if (!file) {
174 FASTLED_WARN("Failed to open file: " << path);
175 return false;
176 }
177 fl::size size = file->size();
178 out->reserve(size + out->size());
179 bool wrote = false;
180 while (file->available()) {
181 u8 buf[64];
182 fl::size n = file->read(buf, sizeof(buf));
183 // out->append(buf, n);
184 out->append((const char *)buf, n);
185 wrote = true;
186 }
187 file->close();
188 FASTLED_DBG_IF(!wrote, "Failed to write any data to the output string.");
189 return wrote;
190}
FileHandlePtr openRead(const char *path)
fl::size size() const
Definition str.h:324
void reserve(fl::size newCapacity)
Definition str.h:370
string & append(const BitsetFixed< N > &bs)
Definition str.h:675
#define FASTLED_DBG_IF(COND, MSG)
Definition dbg.h:64
unsigned char u8
Definition int.h:17
#define FASTLED_WARN
Definition warn.h:7

References fl::string::append(), FASTLED_DBG_IF, FASTLED_WARN, openRead(), fl::StrN< SIZE >::reserve(), and fl::StrN< SIZE >::size().

Referenced by readJson(), readScreenMap(), and readScreenMaps().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: