diff --git a/arm9/source/fatfs/ff.c b/arm9/source/fatfs/ff.c
index d313658b1..45cd82bb8 100644
--- a/arm9/source/fatfs/ff.c
+++ b/arm9/source/fatfs/ff.c
@@ -149,9 +149,11 @@
#define DIR_NTres 12 /* Lower case flag (BYTE) */
#define DIR_CrtTime10 13 /* Created time sub-second (BYTE) */
#define DIR_CrtTime 14 /* Created time (DWORD) */
+#define DIR_CrtDate 16 /* Created date (WORD) */
#define DIR_LstAccDate 18 /* Last accessed date (WORD) */
#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (WORD) */
#define DIR_ModTime 22 /* Modified time (DWORD) */
+#define DIR_ModDate 24 /* Modified date (WORD) */
#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (WORD) */
#define DIR_FileSize 28 /* File size (DWORD) */
#define LDIR_Ord 0 /* LFN: LFN order and LLE flag (BYTE) */
@@ -272,6 +274,7 @@
#define GET_FATTIME() get_fattime()
#endif
+#define GET_FATDATE(tm) ((WORD)(((tm) >> 16) & 0xFFFF))
/* File lock controls */
#if FF_FS_LOCK != 0
@@ -2765,8 +2768,11 @@ static void get_fileinfo (
fno->fattrib = dp->dir[DIR_Attr]; /* Attribute */
fno->fsize = ld_dword(dp->dir + DIR_FileSize); /* Size */
- fno->ftime = ld_word(dp->dir + DIR_ModTime + 0); /* Time */
- fno->fdate = ld_word(dp->dir + DIR_ModTime + 2); /* Date */
+ fno->mod_ftime = ld_word(dp->dir + DIR_ModTime); /* Modified Time */
+ fno->mod_fdate = ld_word(dp->dir + DIR_ModDate); /* Modified Date */
+ fno->crt_ftime = ld_word(dp->dir + DIR_CrtTime); /* Created Time */
+ fno->crt_fdate = ld_word(dp->dir + DIR_CrtDate); /* Created Date */
+ fno->lac_fdate = ld_word(dp->dir + DIR_LstAccDate); /* Last Access Date */
}
#endif /* FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2 */
@@ -3766,9 +3772,12 @@ FRESULT f_open (
} else
#endif
{
+ DWORD tm = GET_FATTIME();
/* Set directory entry initial state */
cl = ld_clust(fs, dj.dir); /* Get current cluster chain */
- st_dword(dj.dir + DIR_CrtTime, GET_FATTIME()); /* Set created time */
+ st_dword(dj.dir + DIR_CrtTime, tm); /* Set created time */
+ st_dword(dj.dir + DIR_ModTime, tm); /* Set modified time */
+ st_word(dj.dir + DIR_LstAccDate, GET_FATDATE(tm)); /* Set last access date */
dj.dir[DIR_Attr] = AM_ARC; /* Reset attribute */
st_clust(fs, dj.dir, 0); /* Reset file allocation info */
st_dword(dj.dir + DIR_FileSize, 0);
@@ -4165,7 +4174,7 @@ FRESULT f_sync (
st_clust(fp->obj.fs, dir, fp->obj.sclust); /* Update file allocation information */
st_dword(dir + DIR_FileSize, (DWORD)fp->obj.objsize); /* Update file size */
st_dword(dir + DIR_ModTime, tm); /* Update modified time */
- st_word(dir + DIR_LstAccDate, 0);
+ st_word(dir + DIR_LstAccDate, GET_FATDATE(tm)); /* Update last access date */
fs->wflag = 1;
res = sync_fs(fs); /* Restore it to the directory */
fp->flag &= (BYTE)~FA_MODIFIED;
@@ -5053,7 +5062,9 @@ FRESULT f_mkdir (
mem_set(fs->win + DIR_Name, ' ', 11); /* Create "." entry */
fs->win[DIR_Name] = '.';
fs->win[DIR_Attr] = AM_DIR;
- st_dword(fs->win + DIR_ModTime, tm);
+ st_dword(fs->win + DIR_ModTime, tm); /* set modified time */
+ st_dword(fs->win + DIR_CrtTime, tm); /* set created time */
+ st_word(fs->win + DIR_LstAccDate, GET_FATDATE(tm)); /* set last access date */
st_clust(fs, fs->win, dcl);
mem_cpy(fs->win + SZDIRE, fs->win, SZDIRE); /* Create ".." entry */
fs->win[SZDIRE + 1] = '.'; pcl = dj.obj.sclust;
@@ -5076,7 +5087,9 @@ FRESULT f_mkdir (
} else
#endif
{
- st_dword(dj.dir + DIR_ModTime, tm); /* Created time */
+ st_dword(fs->win + DIR_ModTime, tm); /* set modified time */
+ st_dword(fs->win + DIR_CrtTime, tm); /* set created time */
+ st_word(fs->win + DIR_LstAccDate, GET_FATDATE(tm)); /* set last access date */
st_clust(fs, dj.dir, dcl); /* Table start cluster */
dj.dir[DIR_Attr] = AM_DIR; /* Attribute */
fs->wflag = 1;
@@ -5283,7 +5296,9 @@ FRESULT f_utime (
} else
#endif
{
- st_dword(dj.dir + DIR_ModTime, (DWORD)fno->fdate << 16 | fno->ftime);
+ st_dword(dj.dir + DIR_ModTime, (DWORD)fno->mod_fdate << 16 | fno->mod_ftime);
+ st_dword(dj.dir + DIR_CrtTime, (DWORD)fno->crt_fdate << 16 | fno->crt_ftime);
+ st_dword(dj.dir + DIR_LstAccDate, fno->lac_fdate);
fs->wflag = 1;
}
if (res == FR_OK) {
diff --git a/arm9/source/fatfs/ff.h b/arm9/source/fatfs/ff.h
index 522504164..16bccd5af 100644
--- a/arm9/source/fatfs/ff.h
+++ b/arm9/source/fatfs/ff.h
@@ -246,8 +246,8 @@ typedef struct {
typedef struct {
FSIZE_t fsize; /* File size */
- WORD fdate; /* Modified date */
- WORD ftime; /* Modified time */
+ WORD mod_fdate; /* Modified date */
+ WORD mod_ftime; /* Modified time */
BYTE fattrib; /* File attribute */
#if FF_USE_LFN
TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */
@@ -255,6 +255,9 @@ typedef struct {
#else
TCHAR fname[12 + 1]; /* File name */
#endif
+ WORD crt_fdate; /* Creation date */
+ WORD crt_ftime; /* Creation time */
+ WORD lac_fdate; /* Last access date */
} FILINFO;
diff --git a/arm9/source/filesys/vff.c b/arm9/source/filesys/vff.c
index aec41a30b..de21b9a6b 100644
--- a/arm9/source/filesys/vff.c
+++ b/arm9/source/filesys/vff.c
@@ -84,8 +84,8 @@ FRESULT fvx_stat (const TCHAR* path, FILINFO* fno) {
if (!GetVirtualFile(&vfile, path, FA_READ)) return FR_NO_PATH;
if (fno) {
fno->fsize = vfile.size;
- fno->fdate = (1<<5)|(1<<0); // 1 for month / day
- fno->ftime = 0;
+ fno->mod_fdate = fno->crt_fdate = fno->lac_fdate = (1<<5)|(1<<0); // 1 for month / day
+ fno->mod_ftime = fno->crt_ftime = 0;
fno->fattrib = (vfile.flags & VFLAG_DIR) ? (AM_DIR|AM_VRT) : AM_VRT;
// could be better...
if (FF_USE_LFN != 0) GetVirtualFilename(fno->fname, &vfile, FF_MAX_LFN + 1);
@@ -137,7 +137,7 @@ FRESULT fvx_readdir (DIR* dp, FILINFO* fno) {
VirtualFile vfile;
if (ReadVirtualDir(&vfile, vdir)) {
fno->fsize = vfile.size;
- fno->fdate = fno->ftime = 0;
+ fno->mod_fdate = fno->crt_fdate = fno->lac_fdate = fno->mod_ftime = fno->crt_ftime = 0;
fno->fattrib = (vfile.flags & VFLAG_DIR) ? (AM_DIR|AM_VRT) : AM_VRT;
GetVirtualFilename(fno->fname, &vfile, FF_MAX_LFN + 1);
} else *(fno->fname) = 0;
diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c
index d0bc1e794..e18d9ba67 100644
--- a/arm9/source/godmode.c
+++ b/arm9/source/godmode.c
@@ -1024,7 +1024,7 @@ u32 CartRawDump(void) {
u32 DirFileAttrMenu(const char* path, const char *name) {
bool drv = (path[2] == '\0');
bool vrt = (!drv); // will be checked below
- char namestr[128], datestr[32], attrstr[128], sizestr[192];
+ char namestr[128], mod_datestr[32], crt_datestr[32], lac_datestr[32], attrstr[128], sizestr[192];
FILINFO fno;
u8 new_attrib;
@@ -1036,12 +1036,21 @@ u32 DirFileAttrMenu(const char* path, const char *name) {
if (fvx_stat(path, &fno) != FR_OK) return 1;
vrt = (fno.fattrib & AM_VRT);
new_attrib = fno.fattrib;
- snprintf(datestr, 32, "%s: %04d-%02d-%02d %02d:%02d:%02d\n",
- (fno.fattrib & AM_DIR) ? "created" : "modified",
- 1980 + ((fno.fdate >> 9) & 0x7F), (fno.fdate >> 5) & 0xF, fno.fdate & 0x1F,
- (fno.ftime >> 11) & 0x1F, (fno.ftime >> 5) & 0x3F, (fno.ftime & 0x1F) << 1);
+ snprintf(mod_datestr, 32, "%s: %04d-%02d-%02d %02d:%02d:%02d\n",
+ "modified",
+ 1980 + ((fno.mod_fdate >> 9) & 0x7F), (fno.mod_fdate >> 5) & 0xF, fno.mod_fdate & 0x1F,
+ (fno.mod_ftime >> 11) & 0x1F, (fno.mod_ftime >> 5) & 0x3F, (fno.mod_ftime & 0x1F) << 1);
+ snprintf(crt_datestr, 32, "%s: %04d-%02d-%02d %02d:%02d:%02d\n",
+ "created ",
+ 1980 + ((fno.crt_fdate >> 9) & 0x7F), (fno.crt_fdate >> 5) & 0xF, fno.crt_fdate & 0x1F,
+ (fno.crt_ftime >> 11) & 0x1F, (fno.crt_ftime >> 5) & 0x3F, (fno.crt_ftime & 0x1F) << 1);
+ snprintf(lac_datestr, 32, "%s: %04d-%02d-%02d\n",
+ "accessed",
+ 1980 + ((fno.lac_fdate >> 9) & 0x7F), (fno.lac_fdate >> 5) & 0xF, fno.lac_fdate & 0x1F);
} else {
- *datestr = '\0';
+ *mod_datestr = '\0';
+ *crt_datestr = '\0';
+ *lac_datestr = '\0';
*attrstr = '\0';
new_attrib = 0;
}
@@ -1095,11 +1104,13 @@ u32 DirFileAttrMenu(const char* path, const char *name) {
ShowString(
"%s\n \n" // name
- "%s" // date (not for drives)
+ "%s" // modified date (not for drives)
+ "%s" // created date (not for drives)
+ "%s\n \n" // accessed date (not for drives)
"%s\n" // size
"%s \n" // attr (not for drives)
"%s\n", // options
- namestr, datestr, sizestr, attrstr,
+ namestr, mod_datestr, crt_datestr, lac_datestr, sizestr, attrstr,
(drv || vrt || (new_attrib == fno.fattrib)) ? "( to continue)" : "( to apply, to cancel)"
);