Fix strict aliasing/alignment violation in FiosIsValidFile

This commit is contained in:
Jonathan G Rennison 2024-09-14 10:04:55 +01:00
parent 99f8989f0c
commit 631e546914

View File

@ -223,7 +223,10 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb
* http://www.gamedev.net/community/forums/topic.asp?topic_id=294070&whichpage=1&#1860504
* XXX - not entirely correct, since filetimes on FAT aren't UTC but local,
* this won't entirely be correct, but we use the time only for comparison. */
sb->st_mtime = (time_t)((*(const uint64_t*)&fd->ftLastWriteTime - posix_epoch_hns) / 1E7);
uint64_t lastWriteTime = fd->ftLastWriteTime.dwHighDateTime;
lastWriteTime <<= 32;
lastWriteTime |= fd->ftLastWriteTime.dwLowDateTime;
sb->st_mtime = (time_t)((lastWriteTime - posix_epoch_hns) / 1E7);
sb->st_mode = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG;
return true;