Added usedBytes to match other filesystems (#4534)

This commit is contained in:
lbernstone
2020-11-14 23:48:21 -07:00
committed by GitHub
parent 378b6ac032
commit d8b1fc81c0
2 changed files with 16 additions and 0 deletions

View File

@ -135,6 +135,21 @@ size_t F_Fat::totalBytes()
return tot_sect * sect_size;
}
size_t F_Fat::usedBytes()
{
FATFS *fs;
DWORD free_clust, used_sect, sect_size;
BYTE pdrv = ff_diskio_get_pdrv_wl(_wl_handle);
char drv[3] = {(char)(48+pdrv), ':', 0};
if ( f_getfree(drv, &free_clust, &fs) != FR_OK){
return 0;
}
used_sect = (fs->n_fatent - 2 - free_clust) * fs->csize;
sect_size = CONFIG_WL_SECTOR_SIZE;
return used_sect * sect_size;
}
size_t F_Fat::freeBytes()
{