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

◆ readText()

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

Definition at line 165 of file file_system.cpp.

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