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

◆ readText()

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

Definition at line 167 of file file_system.cpp.

167 {
168 FileHandlePtr file = openRead(path);
169 if (!file) {
170 FASTLED_WARN("Failed to open file: " << path);
171 return false;
172 }
173 size_t size = file->size();
174 out->reserve(size + out->size());
175 bool wrote = false;
176 while (file->available()) {
177 uint8_t buf[64];
178 size_t n = file->read(buf, sizeof(buf));
179 // out->append(buf, n);
180 out->append((const char*)buf, n);
181 wrote = true;
182 }
183 file->close();
184 FASTLED_DBG_IF(!wrote, "Failed to write any data to the output string.");
185 return wrote;
186}
FileHandlePtr openRead(const char *path)
Str & append(const char *str)
Definition str.h:409
size_t size() const
Definition str.h:245
void reserve(size_t newCapacity)
Definition str.h:284
#define FASTLED_DBG_IF(COND, MSG)
Definition dbg.h:67
#define FASTLED_WARN
Definition warn.h:7

References fl::Str::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: