aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/filesystem.cpp
diff options
context:
space:
mode:
authorZousar Shaker <[email protected]>2024-12-06 21:47:11 -0700
committerZousar Shaker <[email protected]>2024-12-06 21:47:11 -0700
commit5688fa8f46fe3cd32f283adcc590e447174c58a8 (patch)
treedccaef1a87cf454639f45e330732221ce4eb1712 /src/zencore/filesystem.cpp
parentchangelog (diff)
parent5.5.16-pre0 (diff)
downloadzen-zs/xrepo.tar.xz
zen-zs/xrepo.zip
Merge branch 'main' into zs/xrepozs/xrepo
Diffstat (limited to 'src/zencore/filesystem.cpp')
-rw-r--r--src/zencore/filesystem.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp
index 36147c5a9..52f2c4adc 100644
--- a/src/zencore/filesystem.cpp
+++ b/src/zencore/filesystem.cpp
@@ -1435,12 +1435,34 @@ FileSizeFromHandle(void* NativeHandle)
int Fd = int(intptr_t(NativeHandle));
struct stat Stat;
fstat(Fd, &Stat);
- FileSize = size_t(Stat.st_size);
+ FileSize = size_t(Stat.st_size);
#endif
return FileSize;
}
+uint64_t
+GetModificationTickFromHandle(void* NativeHandle, std::error_code& Ec)
+{
+#if ZEN_PLATFORM_WINDOWS
+ FILETIME LastWriteTime;
+ BOOL OK = GetFileTime((HANDLE)NativeHandle, NULL, NULL, &LastWriteTime);
+ if (OK)
+ {
+ return ((uint64_t(LastWriteTime.dwHighDateTime) << 32) | LastWriteTime.dwLowDateTime);
+ }
+#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
+ int Fd = int(uintptr_t(NativeHandle));
+ struct stat Stat;
+ if (0 == fstat(Fd, &Stat))
+ {
+ return gsl::narrow<uint64_t>(Stat.st_mtime);
+ }
+#endif
+ Ec = MakeErrorCodeFromLastError();
+ return 0;
+}
+
std::filesystem::path
GetRunningExecutablePath()
{