diff --git a/build.zig b/build.zig index fbef277..34e5c05 100644 --- a/build.zig +++ b/build.zig @@ -35,6 +35,7 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, }); + exe.linkLibC(); // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default diff --git a/src/config.zig b/src/config.zig index 4e3c89c..a793da2 100644 --- a/src/config.zig +++ b/src/config.zig @@ -107,7 +107,7 @@ pub fn init(alloc: Allocator) !void { } pub fn config_file_path() []const u8 { - const home_path = std.os.getenv("HOME").?; + const home_path = std.posix.getenv("HOME").?; const home_dir = std.fs.openDirAbsolute(home_path, .{}) catch unreachable; const config_path = std.fs.path.join(allocator, &.{ home_path, ".config", "zootdeck" }) catch unreachable; home_dir.makePath(config_path) catch unreachable; @@ -121,7 +121,7 @@ pub fn readfile(filename: []const u8) !Settings { cwd.access(filename, .{}) catch |err| switch (err) { error.FileNotFound => { warn("Warning: creating new {s}\n", .{filename}); - try cwd.writeFile(filename, "{}\n"); + try cwd.writeFile(.{ .sub_path = filename, .data = "{}\n" }); }, else => return err, }; diff --git a/src/db/file.zig b/src/db/file.zig index 70c544d..7daa851 100644 --- a/src/db/file.zig +++ b/src/db/file.zig @@ -6,7 +6,7 @@ const Allocator = std.mem.Allocator; const cache_dir = "./cache"; pub fn init() !void { - std.os.mkdir(cache_dir, 0o644) catch |err| { + std.posix.mkdir(cache_dir, 0o644) catch |err| { if (err != error.PathAlreadyExists) return err; }; } diff --git a/src/db/lmdb.zig b/src/db/lmdb.zig index f2dc284..fead32d 100644 --- a/src/db/lmdb.zig +++ b/src/db/lmdb.zig @@ -23,7 +23,7 @@ pub fn init(allocator: Allocator) !void { warn("mdb_env_set_mapsize failed {}\n", .{mdb_ret}); return error.BadValue; } - std.os.mkdir(dbpath, 0o0755) catch {}; + std.posix.mkdir(dbpath, 0o0755) catch {}; mdb_ret = c.mdb_env_open(env, util.sliceToCstr(allocator, dbpath), 0, 0o644); if (mdb_ret != 0) { warn("mdb_env_open failed {}\n", .{mdb_ret}); diff --git a/src/util.zig b/src/util.zig index ba9fd6c..204bcbc 100644 --- a/src/util.zig +++ b/src/util.zig @@ -14,7 +14,7 @@ pub fn sliceAddNull(allocator: Allocator, str: []const u8) []const u8 { pub fn sliceToCstr(allocator: Allocator, str: []const u8) [*]u8 { var str_null: []u8 = allocator.alloc(u8, str.len + 1) catch unreachable; - std.mem.copy(u8, str_null[0..], str); + std.mem.copyForwards(u8, str_null[0..], str); str_null[str.len] = 0; return str_null.ptr; } @@ -30,8 +30,8 @@ pub fn log(comptime msg: []const u8, args: anytype) void { const tid = thread.self(); const tid_name = thread.name(tid); //const tz = std.os.timezone.tz_minuteswest; - var tz = std.os.timezone{ .tz_minuteswest = 0, .tz_dsttime = 0 }; - std.os.gettimeofday(null, &tz); // does not set tz + var tz = std.posix.timezone{ .tz_minuteswest = 0, .tz_dsttime = 0 }; + std.posix.gettimeofday(null, &tz); // does not set tz const time_str = "Z"; //std.fmt.allocPrint(alloc, "{d}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}:{d:0>2}", .{ yday.year, mday.month.numeric(), mday.day_index + 1, dsec.getHoursIntoDay(), dsec.getMinutesIntoHour(), dsec.getSecondsIntoMinute() }) catch unreachable; _ = time_str; _ = tid_name;