From 17cec3c7f6cb46d8d80c2364eba8296f6dd01ef3 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Fri, 3 Oct 2025 19:01:17 +0200 Subject: use canonical duck typing for function names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- src/gen.zig | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/gen.zig') diff --git a/src/gen.zig b/src/gen.zig index 6d2f124..0504d39 100644 --- a/src/gen.zig +++ b/src/gen.zig @@ -22,7 +22,7 @@ fn genIndexHtml(ctx: *Context) !void { ctx.progress_start("index.html"); defer ctx.progress_end(); - const srcpathIndex = try fs.join_path_and_filename(ctx.allocator(), &.{Context.params.PAGE_PATH}, &.{"index.htm"}); + const srcpathIndex = try fs.joinPathAndFilename(ctx.allocator(), &.{Context.params.PAGE_PATH}, &.{"index.htm"}); defer ctx.allocator().free(srcpathIndex); const f = try fs.FileSwapper.createAt(ctx.allocator(), srcpathIndex); @@ -48,8 +48,8 @@ fn genIndexHtml(ctx: *Context) !void { for (ctx.pages.items) |p| { if (std.mem.startsWith(u8, p, "meta.")) continue; - const dstname = try fs.strip_extension(p); - const dstpath = try fs.join_path_and_filename(ctx.allocator(), &.{Context.params.SITE_PATH}, &.{ dstname, ".html" }); + const dstname = try fs.stripExtension(p); + const dstpath = try fs.joinPathAndFilename(ctx.allocator(), &.{Context.params.SITE_PATH}, &.{ dstname, ".html" }); defer ctx.allocator().free(dstpath); try f.writer().print( @@ -79,10 +79,10 @@ fn genSite(ctx: *Context) !void { continue; } - const dstname = try fs.strip_extension(p); - const srcpath = try fs.join_path_and_filename(ctx.allocator(), &.{Context.params.PAGE_PATH}, &.{ dstname, ".htm" }); + const dstname = try fs.stripExtension(p); + const srcpath = try fs.joinPathAndFilename(ctx.allocator(), &.{Context.params.PAGE_PATH}, &.{ dstname, ".htm" }); defer ctx.allocator().free(srcpath); - const dstpath = try fs.join_path_and_filename(ctx.allocator(), &.{Context.params.SITE_PATH}, &.{ dstname, ".html" }); + const dstpath = try fs.joinPathAndFilename(ctx.allocator(), &.{Context.params.SITE_PATH}, &.{ dstname, ".html" }); defer ctx.allocator().free(dstpath); const rel_dstpath = try std.fs.path.relative(ctx.allocator(), Context.params.SITE_PATH, dstpath); defer ctx.allocator().free(rel_dstpath); @@ -90,7 +90,7 @@ fn genSite(ctx: *Context) !void { log.debug("generating {s} at {s}", .{ p, rel_dstpath }); if (std.fs.path.dirname(rel_dstpath)) |d| { - const dstdir = try fs.join_path_and_filename(ctx.allocator(), &.{Context.params.SITE_PATH}, &.{d}); + const dstdir = try fs.joinPathAndFilename(ctx.allocator(), &.{Context.params.SITE_PATH}, &.{d}); defer ctx.allocator().free(dstdir); try std.fs.cwd().makePath(dstdir); @@ -109,8 +109,8 @@ fn genSite(ctx: *Context) !void { // build a single html file fn build(allocator: std.mem.Allocator, w: std.io.AnyWriter, page_name: []const u8, srcpath: []const u8) !void { - const mtime = try fs.get_mtime(allocator, srcpath); - const mtime_str = try fs.format_mtime(allocator, mtime, "%F"); + const mtime = try fs.getMtime(allocator, srcpath); + const mtime_str = try fs.formatMtime(allocator, mtime, "%F"); defer allocator.free(mtime_str); // HEAD @@ -208,9 +208,9 @@ fn meta(ctx: *Context, p: []const u8) !void { if (std.mem.startsWith(u8, p, "meta.tilde.")) { const dot = std.mem.indexOfPosLinear(u8, p, 11, "."); const dstname = p[11..dot.?]; - const srcpath = try fs.join_path_and_filename(ctx.allocator(), &.{Context.params.PAGE_PATH}, &.{p}); + const srcpath = try fs.joinPathAndFilename(ctx.allocator(), &.{Context.params.PAGE_PATH}, &.{p}); defer ctx.allocator().free(srcpath); - const dstpath = try fs.join_path_and_filename(ctx.allocator(), &.{Context.params.LINK_PATH}, &.{ "~", dstname }); + const dstpath = try fs.joinPathAndFilename(ctx.allocator(), &.{Context.params.LINK_PATH}, &.{ "~", dstname }); defer ctx.allocator().free(dstpath); const link = blk: { @@ -333,8 +333,8 @@ const Page = struct { const endofref = std.mem.lastIndexOf(u8, refname, "#") orelse refname.len; const basename = try std.mem.replaceOwned(u8, arena.allocator(), refname[0..endofref], " ", "_"); - const html = try fs.join_path_and_filename(arena.allocator(), &.{Context.params.SITE_PATH}, &.{ basename, ".html" }); - const htm = try fs.join_path_and_filename(arena.allocator(), &.{Context.params.PAGE_PATH}, &.{ basename, ".htm" }); + const html = try fs.joinPathAndFilename(arena.allocator(), &.{Context.params.SITE_PATH}, &.{ basename, ".html" }); + const htm = try fs.joinPathAndFilename(arena.allocator(), &.{Context.params.PAGE_PATH}, &.{ basename, ".htm" }); try std.fs.cwd().access(htm, .{ .mode = .read_only }); -- cgit 1.4.1