| 313 | } |
| 314 | |
| 315 | void printDirectory(const char* path) |
| 316 | { |
| 317 | auto printStream = [](IDataSourceStream& stream) { |
| 318 | // Use an intermediate memory stream so debug information doesn't get mixed into output |
| 319 | // MemoryDataStream mem; |
| 320 | // mem.copyFrom(&stream); |
| 321 | // Serial.copyFrom(&mem); |
| 322 | Serial.copyFrom(&stream); |
| 323 | }; |
| 324 | |
| 325 | { |
| 326 | auto dir = new Directory; |
| 327 | if(!dir->open(path)) { |
| 328 | debug_e("Open '%s' failed: %s", path, dir->getLastErrorString().c_str()); |
| 329 | delete dir; |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | auto source = new FlashMemoryStream(listing_txt); |
| 334 | IFS::DirectoryTemplate tmpl(source, dir); |
| 335 | printStream(tmpl); |
| 336 | } |
| 337 | |
| 338 | { |
| 339 | auto dir = new Directory; |
| 340 | if(!dir->open(path)) { |
| 341 | debug_e("Open '%s' failed: %s", path, dir->getLastErrorString().c_str()); |
| 342 | delete dir; |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | auto source = new FlashMemoryStream(listing_json); |
| 347 | IFS::JsonDirectoryTemplate tmpl(source, dir); |
| 348 | printStream(tmpl); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | void copySomeFiles() |
| 353 | { |