diff --git a/Dir.zig b/Dir.zig index 1229cbcd73b0713dc8706e730382afe714cd2cb9..331cb8b1ece00dde355a7e5467f19858bf891543 100644 --- a/Dir.zig +++ b/Dir.zig @@ -9,6 +9,7 @@ const os = builtin.target.os.tag; const sys = switch (os) { .linux => @import("sys-linux"), + .macos => @import("sys-darwin"), else => unreachable, }; diff --git a/File.zig b/File.zig index 1bd59e1a6794cbf72d3d3611ed35c323aa52f2a8..9f6814e9bfa5afc967c335b8648c9d086460dde5 100644 --- a/File.zig +++ b/File.zig @@ -11,6 +11,7 @@ const os = builtin.target.os.tag; const sys = switch (os) { .linux => @import("sys-linux"), + .macos => @import("sys-darwin"), else => unreachable, }; @@ -151,6 +152,16 @@ pub const Stat = struct { .ctime = @as(i128, st.ctim.sec) * time.ns_per_s + st.ctim.nsec, }; } + if (os == .macos) { + return .{ + .inode = st.ino, + .size = @bitCast(st.size), + .mode = st.mode, + .atime = @as(i128, st.atimespec.sec) * time.ns_per_s + st.atimespec.nsec, + .mtime = @as(i128, st.mtimespec.sec) * time.ns_per_s + st.mtimespec.nsec, + .ctime = @as(i128, st.ctimespec.sec) * time.ns_per_s + st.ctimespec.nsec, + }; + } } pub fn kind(self: Stat) Kind { diff --git a/licenses.txt b/licenses.txt index 9f661b032bf1c752c0aed3b7d724584bd4eed047..2dcdcfa75569b528bdaf5ac96086de1aaf8fcdf2 100644 --- a/licenses.txt +++ b/licenses.txt @@ -6,6 +6,7 @@ MPL-2.0: MIT: = https://spdx.org/licenses/MIT - git https://github.com/nektro/zig-extras +- git https://github.com/nektro/zig-sys-darwin - git https://github.com/nektro/zig-sys-linux - git https://github.com/nektro/zig-time diff --git a/nfs.zig b/nfs.zig index 7b5149634b270780124f61eb0763b2a3f227db8b..f0d181390891ab9a49429b22a3fc40ed6378e8b8 100644 --- a/nfs.zig +++ b/nfs.zig @@ -9,12 +9,12 @@ const os = builtin.target.os.tag; const sys = switch (os) { .linux => sys_linux, + .macos => @import("sys-darwin"), else => unreachable, }; -pub const Handle = switch (os) { - .linux => enum(c_int) { _ }, - else => unreachable, +pub const Handle = enum(c_int) { + _, }; pub const Error = sys.errno.Error; diff --git a/zigmod.yml b/zigmod.yml index 19f9158232468a6bdb3ae5623ada46f5717e9a11..5341a743a350c5a43f45103ea21ab27ba1b1a8ad 100644 --- a/zigmod.yml +++ b/zigmod.yml @@ -9,3 +9,4 @@ dependencies: - src: git https://github.com/nektro/zig-sys-linux - src: git https://github.com/nektro/zig-nio - src: git https://github.com/nektro/zig-time + - src: git https://github.com/nektro/zig-sys-darwin