| 178 | } |
| 179 | |
| 180 | bool FileSystem::readText(const char *path, fl::string *out) { |
| 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 | } |
| 199 | |
| 200 | } // namespace fl |
| 201 | |