[*] Stats now return nanoseconds timestamps
This commit is contained in:
parent
75ad160559
commit
2fdf730263
@ -24,9 +24,10 @@ namespace Aurora::IO::FS
|
||||
// to UNIX using AuTime::ConvertAuroraToUnixMS
|
||||
// to AuTime::tm (interchangeable) using AuTime::ToCivilTime
|
||||
// to string using AuLocale::TimeDateTo[...]
|
||||
AuInt64 created;
|
||||
AuInt64 modified;
|
||||
AuInt64 accessed;
|
||||
// Updated Apr/2023: these are now in nanoseconds. Convert to AuNSToMS<T>(...)
|
||||
AuInt64 createdNs;
|
||||
AuInt64 modifiedNs;
|
||||
AuInt64 accessedNs;
|
||||
|
||||
AuUInt64 uSize;
|
||||
};
|
||||
|
@ -77,9 +77,9 @@ namespace Aurora::IO::FS
|
||||
|
||||
stat.uSize = AuUInt64(this->ffd.nFileSizeLow) | (AuUInt64(this->ffd.nFileSizeHigh) << 32);
|
||||
|
||||
stat.created = Time::ConvertTimestamp(this->ffd.ftCreationTime);
|
||||
stat.modified = Time::ConvertTimestamp(this->ffd.ftLastWriteTime);
|
||||
stat.accessed = Time::ConvertTimestamp(this->ffd.ftLastAccessTime);
|
||||
stat.createdNs = Time::ConvertTimestampNs(this->ffd.ftCreationTime);
|
||||
stat.modifiedNs = Time::ConvertTimestampNs(this->ffd.ftLastWriteTime);
|
||||
stat.accessedNs = Time::ConvertTimestampNs(this->ffd.ftLastAccessTime);
|
||||
|
||||
return &stat;
|
||||
}
|
||||
@ -470,9 +470,9 @@ namespace Aurora::IO::FS
|
||||
|
||||
stat.uSize = AuUInt64(data.nFileSizeLow) | (AuUInt64(data.nFileSizeHigh) << 32);
|
||||
|
||||
stat.created = Time::ConvertTimestamp(data.ftCreationTime);
|
||||
stat.modified = Time::ConvertTimestamp(data.ftLastWriteTime);
|
||||
stat.accessed = Time::ConvertTimestamp(data.ftLastAccessTime);
|
||||
stat.createdNs = Time::ConvertTimestampNs(data.ftCreationTime);
|
||||
stat.modifiedNs = Time::ConvertTimestampNs(data.ftLastWriteTime);
|
||||
stat.accessedNs = Time::ConvertTimestampNs(data.ftLastAccessTime);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -459,9 +459,16 @@ namespace Aurora::IO::FS
|
||||
|
||||
stat.uSize = s.st_size;
|
||||
|
||||
stat.created = Time::CTimeToMS(s.st_ctime);
|
||||
stat.modified = Time::CTimeToMS(s.st_mtime);
|
||||
stat.accessed = Time::CTimeToMS(s.st_atime);
|
||||
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
stat.createdNs = AuTime::CTimeNSNormalize(s.st_ctime_nsec);
|
||||
stat.modifiedNs = AuTime::CTimeNSNormalize(s.st_mtime_nsec);
|
||||
stat.accessedNs = AuTime::CTimeNSNormalize(s.st_atime_nsec);
|
||||
#else
|
||||
stat.createdNs = AuMSToNS<AuUInt64>(Time::CTimeToMS(s.st_ctime));
|
||||
stat.modifiedNs = AuMSToNS<AuUInt64>(Time::CTimeToMS(s.st_mtime));
|
||||
stat.accessedNs = AuMSToNS<AuUInt64>(Time::CTimeToMS(s.st_atime));
|
||||
#endif
|
||||
|
||||
err = lstat(path.c_str(), &s);
|
||||
if (err != -1)
|
||||
|
@ -214,6 +214,11 @@ namespace Aurora::Time
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(NormalizeEpoch(sys_clock::from_time_t(time).time_since_epoch())).count();
|
||||
}
|
||||
|
||||
AuInt64 CTimeNSNormalize(AuUInt64 time)
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(NormalizeEpoch(std::chrono::nanoseconds(time))).count();
|
||||
}
|
||||
|
||||
AUKN_SYM AuUInt64 ThreadClockNS()
|
||||
{
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
namespace Aurora::Time
|
||||
{
|
||||
AuInt64 CTimeNSNormalize(AuUInt64 time);
|
||||
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
|
||||
static AuInt64 ConvertTimestamp(const FILETIME &ft)
|
||||
@ -23,6 +25,14 @@ namespace Aurora::Time
|
||||
return (ull.QuadPart - 126'435'537'000'000'000ull) / 10'000ULL;
|
||||
}
|
||||
|
||||
static AuInt64 ConvertTimestampNs(const FILETIME &ft)
|
||||
{
|
||||
ULARGE_INTEGER ull;
|
||||
ull.LowPart = ft.dwLowDateTime;
|
||||
ull.HighPart = ft.dwHighDateTime;
|
||||
return (ull.QuadPart - 126'435'537'000'000'000ull) * 100ULL;
|
||||
}
|
||||
|
||||
static AuInt64 ConvertTimestamp(AuUInt64 timeIn)
|
||||
{
|
||||
return (126'435'537'000'000'000ull) + (AuUInt64(timeIn) * 10000ULL);
|
||||
|
Loading…
Reference in New Issue
Block a user