RTAkland
04/18/2025, 7:00 AMFilipp Zhinkin
04/18/2025, 12:15 PMRTAkland
04/18/2025, 12:15 PMRTAkland
04/18/2025, 12:17 PMFilipp Zhinkin
04/18/2025, 1:03 PMimport kotlinx.cinterop.*
import platform.posix.*
import kotlin.time.*
@OptIn(ExperimentalTime::class, ExperimentalForeignApi::class, UnsafeNumber::class)
public fun getMTime(path: Path): Instant {
memScoped {
val stat = alloc<stat>()
if (lstat(path.toString(), stat.ptr) != 0) {
throw IllegalStateException("Failed to get mtime for $path")
}
return Instant.fromEpochSeconds(stat.st_mtim.tv_sec.toLong(), stat.st_mtim.tv_nsec)
}
}
RTAkland
04/18/2025, 1:04 PM