| ... | @@ -46,27 +46,7 @@ pub fn anyReadable(self: File) nio.AnyReadable { | ... | @@ -46,27 +46,7 @@ pub fn anyReadable(self: File) nio.AnyReadable { |
| 46 | | 46 | |
| 47 | pub fn stat(self: File) !Stat { | 47 | pub fn stat(self: File) !Stat { |
| 48 | if (os != .linux) @compileError("TODO: File.stat"); | 48 | if (os != .linux) @compileError("TODO: File.stat"); |
| 49 | const st = try sys_linux.fstat(@intFromEnum(self.fd)); | 49 | return .fromPosix(try sys_linux.fstat(@intFromEnum(self.fd))); |
| 50 | if (builtin.target.cpu.arch.isMIPS64()) { | | |
| 51 | return .{ | | |
| 52 | .inode = st.ino, | | |
| 53 | .size = @bitCast(st.size), | | |
| 54 | .mode = st.mode, | | |
| 55 | .kind = {}, | | |
| 56 | .atime = @as(i128, st.atim) * time.ns_per_s + st.atim_nsec, | | |
| 57 | .mtime = @as(i128, st.mtim) * time.ns_per_s + st.mtim_nsec, | | |
| 58 | .ctime = @as(i128, st.ctim) * time.ns_per_s + st.ctim_nsec, | | |
| 59 | }; | | |
| 60 | } | | |
| 61 | return .{ | | |
| 62 | .inode = st.ino, | | |
| 63 | .size = @bitCast(st.size), | | |
| 64 | .mode = st.mode, | | |
| 65 | .kind = {}, | | |
| 66 | .atime = @as(i128, st.atim.sec) * time.ns_per_s + st.atim.nsec, | | |
| 67 | .mtime = @as(i128, st.mtim.sec) * time.ns_per_s + st.mtim.nsec, | | |
| 68 | .ctime = @as(i128, st.ctim.sec) * time.ns_per_s + st.ctim.nsec, | | |
| 69 | }; | | |
| 70 | } | 50 | } |
| 71 | | 51 | |
| 72 | pub fn getEndPos(self: File) !u64 { | 52 | pub fn getEndPos(self: File) !u64 { |
| ... | @@ -117,6 +97,29 @@ pub const Stat = struct { | ... | @@ -117,6 +97,29 @@ pub const Stat = struct { |
| 117 | mtime: i128, | 97 | mtime: i128, |
| 118 | /// Last status/metadata change time in nanoseconds, relative to UTC 1970-01-01. | 98 | /// Last status/metadata change time in nanoseconds, relative to UTC 1970-01-01. |
| 119 | ctime: i128, | 99 | ctime: i128, |
| | 100 | |
| | 101 | pub fn fromPosix(st: sys_linux.struct_stat) Stat { |
| | 102 | if (os == .linux) { |
| | 103 | if (builtin.target.cpu.arch.isMIPS64()) { |
| | 104 | return .{ |
| | 105 | .inode = st.ino, |
| | 106 | .size = @bitCast(st.size), |
| | 107 | .mode = st.mode, |
| | 108 | .atime = @as(i128, st.atim) * time.ns_per_s + st.atim_nsec, |
| | 109 | .mtime = @as(i128, st.mtim) * time.ns_per_s + st.mtim_nsec, |
| | 110 | .ctime = @as(i128, st.ctim) * time.ns_per_s + st.ctim_nsec, |
| | 111 | }; |
| | 112 | } |
| | 113 | return .{ |
| | 114 | .inode = st.ino, |
| | 115 | .size = @bitCast(st.size), |
| | 116 | .mode = st.mode, |
| | 117 | .atime = @as(i128, st.atim.sec) * time.ns_per_s + st.atim.nsec, |
| | 118 | .mtime = @as(i128, st.mtim.sec) * time.ns_per_s + st.mtim.nsec, |
| | 119 | .ctime = @as(i128, st.ctim.sec) * time.ns_per_s + st.ctim.nsec, |
| | 120 | }; |
| | 121 | } |
| | 122 | } |
| 120 | }; | 123 | }; |
| 121 | | 124 | |
| 122 | pub const INode = switch (builtin.target.os.tag) { | 125 | pub const INode = switch (builtin.target.os.tag) { |