A fork of the original SDFileSystem, added only stat() for getting file information.
Added code to the original SDFileSystem to export the stat() command. It would now be possible to get the FILEINFO struct of a directory entry to get information such as file size, etc.
SDFileSystem2 usage
#include "SDFileSystem.h" SDFileSystem sd(p5,p6,p7,p8,"sd"); // mosi, miso, sck, cs static void cmd_ls(Stream * chp, int argc, char * argv[]) { DIR * dp; struct dirent * dirp; FILINFO fileInfo; char dirroot[256]; if (argc >= 1) sprintf(dirroot, "/sd/%s", argv[0]); else sprintf(dirroot, "/sd"); chp->printf("Listing directory [%s]\r\n", dirroot); dp = opendir(dirroot); while((dirp = readdir(dp)) != NULL) { if (sd.stat(dirp->d_name, &fileInfo) == 0) { if (fileInfo.fattrib & AM_DIR ) chp->printf("<DIR>\t\t"); else chp->printf("%ld\t\t", fileInfo.fsize); } chp->printf("%s\r\n", dirp->d_name); } closedir(dp); }
Files at revision 0:572d27f56fcd
Name | Size | Actions |
---|---|---|
[up] | ||
ChaN | ||
FATDirHandle.cpp | 2284 | Revisions Annotate |
FATDirHandle.h | 1586 | Revisions Annotate |
FATFileHandle.cpp | 2637 | Revisions Annotate |
FATFileHandle.h | 1645 | Revisions Annotate |
FATFileSystem.cpp | 4293 | Revisions Annotate |
FATFileSystem.h | 2802 | Revisions Annotate |
MemFileSystem.h | 2148 | Revisions Annotate |