|
|
@ -719,11 +719,18 @@ void FiosGetDrives(void)
|
|
|
|
|
|
|
|
|
|
|
|
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
|
|
|
|
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// hectonanoseconds between Windows and POSIX epoch
|
|
|
|
|
|
|
|
static const int64 posix_epoch_hns = 0x019DB1DED53E8000;
|
|
|
|
const WIN32_FIND_DATA *fd = &ent->dir->fd;
|
|
|
|
const WIN32_FIND_DATA *fd = &ent->dir->fd;
|
|
|
|
if (fd->dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) return false;
|
|
|
|
if (fd->dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
sb->st_size = ((uint64) fd->nFileSizeHigh << 32) + fd->nFileSizeLow;
|
|
|
|
sb->st_size = ((uint64) fd->nFileSizeHigh << 32) + fd->nFileSizeLow;
|
|
|
|
sb->st_mtime = *(uint64*)&fd->ftLastWriteTime;
|
|
|
|
/* UTC FILETIME to seconds-since-1970 UTC
|
|
|
|
|
|
|
|
* we just have to subtract POSIX epoch and scale down to units of seconds.
|
|
|
|
|
|
|
|
* http://www.gamedev.net/community/forums/topic.asp?topic_id=294070&whichpage=1�
|
|
|
|
|
|
|
|
* 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 comparsion. */
|
|
|
|
|
|
|
|
sb->st_mtime = (time_t)((*(uint64*)&fd->ftLastWriteTime - posix_epoch_hns) / 1E7);
|
|
|
|
sb->st_mode = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG;
|
|
|
|
sb->st_mode = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|