MCPcopy Create free account
hub / github.com/BruceDevices/firmware / fileInfo

Function fileInfo

src/core/sd_functions.cpp:970–1004  ·  view source on GitHub ↗

** Function: fileInfo ** Display file info **********************************************************************/

Source from the content-addressed store, hash-verified

968** Display file info
969**********************************************************************/
970void fileInfo(FS fs, String filepath) {
971 File file = fs.open(filepath, FILE_READ);
972 if (!file) return;
973
974 int bytesize = file.size();
975 float filesize = bytesize;
976 String unit = "B";
977
978 time_t modifiedTime = file.getLastWrite();
979
980 if (filesize >= 1000000) {
981 filesize /= 1000000.0;
982 unit = "MB";
983 } else if (filesize >= 1000) {
984 filesize /= 1000.0;
985 unit = "kB";
986 }
987
988 drawMainBorderWithTitle("FILE INFO");
989 padprintln("");
990 padprintln("Path: " + filepath);
991 padprintln("");
992 padprintf("Bytes: %d\n", bytesize);
993 padprintln("");
994 padprintf("Size: %.02f %s\n", filesize, unit.c_str());
995 padprintln("");
996 padprintf("Modified: %s\n", ctime(&modifiedTime));
997
998 file.close();
999 delay(100);
1000
1001 while (!check(EscPress) && !check(SelPress)) { delay(100); }
1002
1003 return;
1004}
1005
1006/*********************************************************************
1007** Function: createNewFile

Callers 1

loopSDFunction · 0.85

Calls 6

drawMainBorderWithTitleFunction · 0.85
padprintlnFunction · 0.85
padprintfFunction · 0.85
checkFunction · 0.85
sizeMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected