commit 55077435bf53bb8273e1b23c1690798312d6abc6 (tree)
parent cf38ce970155512577cfb0cc281d1a308af7e7e9
Author: LeRoyce Pearson <leroycepearson@geemili.xyz>
Date: Sun, 8 Mar 2020 14:27:49 -0600
Expose file inode (linux) and file index (windows)
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig
@@ -28,6 +28,10 @@ pub const File = struct {
pub const async_block_allowed_no = if (io.is_async) false else {};
pub const Mode = os.mode_t;
+ pub const INode = switch (builtin.os.tag) {
+ .windows => os.windows.LARGE_INTEGER,
+ else => u64,
+ };
pub const default_mode = switch (builtin.os.tag) {
.windows => 0,
@@ -145,6 +149,7 @@ pub const File = struct {
}
pub const Stat = struct {
+ inode: INode,
size: u64,
mode: Mode,
@@ -174,6 +179,7 @@ pub const File = struct {
else => return windows.unexpectedStatus(rc),
}
return Stat{
+ .inode = info.InternalInformation.IndexNumber,
.size = @bitCast(u64, info.StandardInformation.EndOfFile),
.mode = 0,
.atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),
@@ -187,6 +193,7 @@ pub const File = struct {
const mtime = st.mtime();
const ctime = st.ctime();
return Stat{
+ .inode = st.ino,
.size = @bitCast(u64, st.size),
.mode = st.mode,
.atime = @as(i64, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec,