FastLED 3.10.6
Loading...
Searching...
No Matches

◆ readText()

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

Definition at line 191 of file fs.cpp.hpp.

191 {
192 fl::ifstream file = openRead(path);
193 if (!file.is_open()) {
194 FL_WARN("Failed to open file: %s", path);
195 return false;
196 }
197 fl::size size = file.size();
198 out->reserve(size + out->size());
199 bool wrote = false;
200 while (file.available()) {
201 u8 buf[64];
202 fl::size n = file.read(buf, sizeof(buf));
203 out->append((const char *)buf, n);
204 wrote = true;
205 }
206 file.close();
207 FL_DBG_IF(!wrote, "Failed to write any data to the output string.");
208 return wrote;
209}
fl::ifstream openRead(const char *path)
Definition fs.cpp.hpp:170
void reserve(fl::size newCapacity) FL_NO_EXCEPT
fl::size size() const FL_NO_EXCEPT
bool available() const
Definition fstream.h:161
fl::size_t size() const
Definition fstream.h:146
ifstream & read(char *buffer, fl::size_t count)
bool is_open() const
Definition fstream.h:111
string & append(const bitset_fixed< N > &bs) FL_NO_EXCEPT
Definition string.h:293
#define FL_DBG_IF
Definition log.h:565
#define FL_WARN(...)
Definition log.h:440
unsigned char u8
Definition stdint.h:131

References fl::string::append(), fl::ifstream::available(), fl::ifstream::close(), FL_DBG_IF, FL_WARN, fl::ifstream::is_open(), openRead(), fl::ifstream::read(), fl::basic_string::reserve(), fl::basic_string::size(), and fl::ifstream::size().

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

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