From c407e423d9f1299757583905b9adcda0155e82f5 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 24 Jul 2024 13:37:56 +0100 Subject: [PATCH] Add `inode` to `os2.Stat` --- core/os/os2/stat.odin | 3 +++ core/os/os2/stat_linux.odin | 2 ++ core/os/os2/stat_windows.odin | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/os/os2/stat.odin b/core/os/os2/stat.odin index caf46b661..e67045b38 100644 --- a/core/os/os2/stat.odin +++ b/core/os/os2/stat.odin @@ -8,9 +8,12 @@ Fstat_Callback :: proc(f: ^File, allocator: runtime.Allocator) -> (File_Info, Er File_Info :: struct { fullpath: string, name: string, + + inode: u64, size: i64, mode: int, type: File_Type, + creation_time: time.Time, modification_time: time.Time, access_time: time.Time, diff --git a/core/os/os2/stat_linux.odin b/core/os/os2/stat_linux.odin index c09f9b299..39a364c9a 100644 --- a/core/os/os2/stat_linux.odin +++ b/core/os/os2/stat_linux.odin @@ -28,10 +28,12 @@ _fstat_internal :: proc(fd: linux.Fd, allocator: runtime.Allocator) -> (File_Inf case linux.S_IFSOCK: type = .Socket } mode := int(0o7777 & transmute(u32)s.mode) + // TODO: As of Linux 4.11, the new statx syscall can retrieve creation_time fi := File_Info { fullpath = _get_full_path(fd, allocator), name = "", + inode = u64(s.ino), size = i64(s.size), mode = mode, type = type, diff --git a/core/os/os2/stat_windows.odin b/core/os/os2/stat_windows.odin index dcb37f3ab..a3def0ea7 100644 --- a/core/os/os2/stat_windows.odin +++ b/core/os/os2/stat_windows.odin @@ -262,7 +262,8 @@ _file_info_from_get_file_information_by_handle :: proc(path: string, h: win32.HA fi: File_Info fi.fullpath = path fi.name = basename(path) - fi.size = i64(d.nFileSizeHigh)<<32 + i64(d.nFileSizeLow) + fi.inode = u64(d.nFileIndexHigh)<<32 + u64(d.nFileIndexLow) + fi.size = i64(d.nFileSizeHigh)<<32 + i64(d.nFileSizeLow) type, mode := _file_type_mode_from_file_attributes(d.dwFileAttributes, nil, 0) fi.type = type fi.mode |= mode