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); }
Revisions of FATFileSystem/ChaN/ccsbcs.cpp
Revision | Date | Message | Actions |
---|---|---|---|
0:572d27f56fcd | 2015-04-28 | Added stat() to get file information | File Diff Annotate |