Skip to content

Commit 943d2f7

Browse files
Merge pull request #15 from qistoph/pr_volume_ct
Set creation/modification time of volume on root
2 parents 6b5c62d + e38e3d6 commit 943d2f7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

main.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,12 @@ int actionPack() {
559559

560560
littlefsFormat();
561561
int result = addFiles(s_dirName.c_str(), "/");
562+
563+
// Set creation/modification time of volume on root
564+
time_t ct = time(NULL);
565+
lfs_setattr(&s_fs, "/", 't', &ct, sizeof(ct));
566+
lfs_setattr(&s_fs, "/", 'c', &ct, sizeof(ct));
567+
562568
littlefsUnmount();
563569

564570
fwrite(&s_flashmem[0], 4, s_flashmem.size()/4, fdres);
@@ -623,6 +629,12 @@ int actionList() {
623629
fclose(fdsrc);
624630
littlefsMount();
625631
listFiles("");
632+
633+
time_t ct;
634+
if (lfs_getattr(&s_fs, "/", 't', &ct, sizeof(ct)) >= 0) { // and/or check 'c' as well?
635+
std::cout << "Creation time:" << '\t' << asctime(gmtime(&ct));
636+
}
637+
626638
littlefsUnmount();
627639
return 0;
628640
}

0 commit comments

Comments
 (0)