| 317 | } |
| 318 | |
| 319 | EMSCRIPTEN_KEEPALIVE void fastled_declare_files(const char* jsonStr) { |
| 320 | fl::json doc = fl::json::parse(fl::string(jsonStr)); |
| 321 | if (!doc.is_object() || !doc.contains("files")) { |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | auto files = doc["files"]; |
| 326 | if (!files.is_array()) { |
| 327 | return; |
| 328 | } |
| 329 | |
| 330 | size_t fileCount = files.size(); |
| 331 | for (size_t i = 0; i < fileCount; i++) { |
| 332 | auto file = files[i]; |
| 333 | if (!file.is_object()) { |
| 334 | continue; |
| 335 | } |
| 336 | |
| 337 | if (!file.contains("size") || !file.contains("path")) { |
| 338 | continue; |
| 339 | } |
| 340 | |
| 341 | int size = file["size"] | 0; |
| 342 | fl::string path = file["path"] | fl::string(""); |
| 343 | |
| 344 | if (size > 0 && !path.empty()) { |
| 345 | fl::printf("Declaring file %s with size %d. These will become available as " |
| 346 | "File system paths within the app.\n", |
| 347 | path.c_str(), size); |
| 348 | jsDeclareFile(path.c_str(), size); |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | } // extern "C" |
| 354 | |