authorgravatar for leroycepearson@geemili.xyzLeRoyce Pearson <leroycepearson@geemili.xyz> 2020-03-08 14:27:49-06:00
committergravatar for leroycepearson@geemili.xyzLeRoyce Pearson <leroycepearson@geemili.xyz> 2020-03-08 15:19:02-06:00
log55077435bf53bb8273e1b23c1690798312d6abc6
tree1b2c7e1903e61df5eb1b2ca523943a679ecc7aab
parentcf38ce970155512577cfb0cc281d1a308af7e7e9

Expose file inode (linux) and file index (windows)


1 files changed, 7 insertions(+), 0 deletions(-)

lib/std/fs/file.zig+7
...@@ -28,6 +28,10 @@ pub const File = struct {...@@ -28,6 +28,10 @@ pub const File = struct {
28 pub const async_block_allowed_no = if (io.is_async) false else {};28 pub const async_block_allowed_no = if (io.is_async) false else {};
2929
30 pub const Mode = os.mode_t;30 pub const Mode = os.mode_t;
31 pub const INode = switch (builtin.os.tag) {
32 .windows => os.windows.LARGE_INTEGER,
33 else => u64,
34 };
3135
32 pub const default_mode = switch (builtin.os.tag) {36 pub const default_mode = switch (builtin.os.tag) {
33 .windows => 0,37 .windows => 0,
...@@ -145,6 +149,7 @@ pub const File = struct {...@@ -145,6 +149,7 @@ pub const File = struct {
145 }149 }
146150
147 pub const Stat = struct {151 pub const Stat = struct {
152 inode: INode,
148 size: u64,153 size: u64,
149 mode: Mode,154 mode: Mode,
150155
...@@ -174,6 +179,7 @@ pub const File = struct {...@@ -174,6 +179,7 @@ pub const File = struct {
174 else => return windows.unexpectedStatus(rc),179 else => return windows.unexpectedStatus(rc),
175 }180 }
176 return Stat{181 return Stat{
182 .inode = info.InternalInformation.IndexNumber,
177 .size = @bitCast(u64, info.StandardInformation.EndOfFile),183 .size = @bitCast(u64, info.StandardInformation.EndOfFile),
178 .mode = 0,184 .mode = 0,
179 .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),185 .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),
...@@ -187,6 +193,7 @@ pub const File = struct {...@@ -187,6 +193,7 @@ pub const File = struct {
187 const mtime = st.mtime();193 const mtime = st.mtime();
188 const ctime = st.ctime();194 const ctime = st.ctime();
189 return Stat{195 return Stat{
196 .inode = st.ino,
190 .size = @bitCast(u64, st.size),197 .size = @bitCast(u64, st.size),
191 .mode = st.mode,198 .mode = st.mode,
192 .atime = @as(i64, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec,199 .atime = @as(i64, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec,