| 453 | } |
| 454 | |
| 455 | int FileSystem::stat(const char* path, Stat* stat) |
| 456 | { |
| 457 | CHECK_MOUNTED() |
| 458 | |
| 459 | if(isRootPath(path)) { |
| 460 | if(stat != nullptr) { |
| 461 | *stat = Stat{}; |
| 462 | stat->fs = this; |
| 463 | stat->attr += FileAttribute::Directory; |
| 464 | } |
| 465 | return FS_OK; |
| 466 | } |
| 467 | |
| 468 | spiffs_stat ss; |
| 469 | int err = SPIFFS_stat(handle(), path ?: "", &ss); |
| 470 | CHECK_RES(err) |
| 471 | |
| 472 | if(stat != nullptr) { |
| 473 | *stat = Stat{}; |
| 474 | stat->fs = this; |
| 475 | stat->name.copy(reinterpret_cast<const char*>(ss.name)); |
| 476 | stat->size = ss.size; |
| 477 | stat->id = ss.obj_id; |
| 478 | SpiffsMetaBuffer smb; |
| 479 | #ifdef SPIFFS_STORE_META |
| 480 | smb.assign(ss.meta); |
| 481 | #else |
| 482 | smb.init(); |
| 483 | #endif |
| 484 | fillStat(*stat, smb); |
| 485 | checkStat(*stat); |
| 486 | } |
| 487 | |
| 488 | return FS_OK; |
| 489 | } |
| 490 | |
| 491 | int FileSystem::fstat(FileHandle file, Stat* stat) |
| 492 | { |
no test coverage detected