Fork of FATFileSystem that exposes FILINFO in the FATDirHandle. This allows obtaining true file sizes and testing whether a dir pointer is a directory or a file.
Dependents: SDFileSystemNoStall
Fork of FATFileSystem by
Diff: ChaN/diskio.cpp
- Revision:
- 6:7a3c53d25d96
- Parent:
- 4:3ff2606d5713
--- a/ChaN/diskio.cpp Thu Oct 30 06:19:16 2014 +0000 +++ b/ChaN/diskio.cpp Thu Oct 30 07:01:15 2014 +0000 @@ -14,7 +14,7 @@ DSTATUS disk_initialize ( BYTE drv /* Physical drive nmuber (0..) */ -) +) { debug_if(FFS_DBG, "disk_initialize on drv [%d]\n", drv); return (DSTATUS)FATFileSystem::_ffs[drv]->disk_initialize(); @@ -22,7 +22,7 @@ DSTATUS disk_status ( BYTE drv /* Physical drive nmuber (0..) */ -) +) { debug_if(FFS_DBG, "disk_status on drv [%d]\n", drv); return (DSTATUS)FATFileSystem::_ffs[drv]->disk_status(); @@ -36,10 +36,15 @@ ) { debug_if(FFS_DBG, "disk_read(sector %d, count %d) on drv [%d]\n", sector, count, drv); - if (FATFileSystem::_ffs[drv]->disk_read((uint8_t*)buff, sector, count)) - return RES_PARERR; - else - return RES_OK; + for(DWORD s=sector; s<sector+count; s++) { + debug_if(FFS_DBG, " disk_read(sector %d)\n", s); + int res = FATFileSystem::_ffs[drv]->disk_read((uint8_t*)buff, s); + if(res) { + return RES_PARERR; + } + buff += 512; + } + return RES_OK; } #if _READONLY == 0 @@ -51,10 +56,15 @@ ) { debug_if(FFS_DBG, "disk_write(sector %d, count %d) on drv [%d]\n", sector, count, drv); - if (FATFileSystem::_ffs[drv]->disk_write((uint8_t*)buff, sector, count)) - return RES_PARERR; - else - return RES_OK; + for(DWORD s = sector; s < sector + count; s++) { + debug_if(FFS_DBG, " disk_write(sector %d)\n", s); + int res = FATFileSystem::_ffs[drv]->disk_write((uint8_t*)buff, s); + if(res) { + return RES_PARERR; + } + buff += 512; + } + return RES_OK; } #endif /* _READONLY */