Menu

#18 utime in libfat on NDS

open
nobody
devkitARM (6)
5
2012-10-09
2008-03-22
No

int utime(const char filename, const struct utimbuf buf);

utime() changes the access and modification times of the inode specified by filename to the actime and modtime fields of buf respectively.

It wouldn't be too difficult to add to libfat, but devoptab_t doesn't have an entry for the function.

The FAT side of things would require something like:

PARTITION * partition = _FAT_partition_getPartitionFromPath (path);
if (partition == 0 || partition->readOnly)
return;
bool fileExists = _FAT_directory_entryFromPath (partition, &dirEntry, path, NULL);
if (fileExists && !_FAT_directory_isDirectory(&dirEntry))
{
// Set the creation time and date
dirEntry.entryData[DIR_ENTRY_cTime_ms] = 0;
// _FAT_filetime_get*From_time_t do not really exist.
u16_to_u8array (dirEntry.entryData, DIR_ENTRY_cTime, _FAT_filetime_getTimeFrom_time_t( utimbuf->actime ));
u16_to_u8array (dirEntry.entryData, DIR_ENTRY_cDate, _FAT_filetime_getDateFrom_time_t( utimbuf->actime ));
}

Where the _FAT_filetime_get*From_time_t functions would be something like the "inverse" of _FAT_filetime_to_time_t.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.