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

◆ readText()

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

Definition at line 180 of file file_system.cpp.hpp.

180 {
181 fl::ifstream file = openRead(path);
182 if (!file.is_open()) {
183 FL_WARN("Failed to open file: " << path);
184 return false;
185 }
186 fl::size size = file.size();
187 out->reserve(size + out->size());
188 bool wrote = false;
189 while (file.available()) {
190 u8 buf[64];
191 fl::size n = file.read(buf, sizeof(buf));
192 out->append((const char *)buf, n);
193 wrote = true;
194 }
195 file.close();
196 FL_DBG_IF(!wrote, "Failed to write any data to the output string.");
197 return wrote;
198}
fl::ifstream openRead(const char *path)
void reserve(fl::size newCapacity) FL_NOEXCEPT
fl::size size() const FL_NOEXCEPT
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_NOEXCEPT
Definition string.h:284
#define FL_DBG_IF
Definition log.h:389
#define FL_WARN(X)
Definition log.h:276
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: