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/fs.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/fs.zig') diff --git a/src/fs.zig b/src/fs.zig index 7a8717a..d29ee05 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -65,10 +65,10 @@ pub const FileSwapper = struct { } }; -pub fn replace_extension(alloc: std.mem.Allocator, p: []const u8, new: []const u8) ![]const u8 { +pub fn replaceExtension(alloc: std.mem.Allocator, p: []const u8, new: []const u8) ![]const u8 { const dirname = std.fs.path.dirname(p) orelse "."; - const basename = try strip_extension(std.fs.path.basename(p)); - return try join_path_and_filename( + const basename = try stripExtension(std.fs.path.basename(p)); + return try joinPathAndFilename( alloc, &.{dirname}, &.{ basename, ".", new }, @@ -76,14 +76,14 @@ pub fn replace_extension(alloc: std.mem.Allocator, p: []const u8, new: []const u } // also trims off base paths -pub fn strip_extension(path: []const u8) ![]const u8 { +pub fn stripExtension(path: []const u8) ![]const u8 { const ext = std.fs.path.extension(path); const ext_idx = std.mem.indexOfPosLinear(u8, path, 0, ext); std.debug.assert(ext_idx != null); return path[0..ext_idx.?]; } -pub fn join_path_and_filename(alloc: std.mem.Allocator, paths: []const []const u8, filename_parts: []const []const u8) ![]const u8 { +pub fn joinPathAndFilename(alloc: std.mem.Allocator, paths: []const []const u8, filename_parts: []const []const u8) ![]const u8 { const filename = try std.mem.concat(alloc, u8, filename_parts); defer alloc.free(filename); @@ -100,7 +100,7 @@ pub fn join_path_and_filename(alloc: std.mem.Allocator, paths: []const []const u return try std.fs.path.join(alloc, paths2); } -pub fn get_mtime(alloc: std.mem.Allocator, path: []const u8) !std.os.linux.timespec { +pub fn getMtime(alloc: std.mem.Allocator, path: []const u8) !std.os.linux.timespec { const attr = try alloc.create(std.os.linux.Stat); defer alloc.destroy(attr); @@ -115,7 +115,7 @@ pub fn get_mtime(alloc: std.mem.Allocator, path: []const u8) !std.os.linux.times } // use libc strftime to format time string -pub fn format_mtime(alloc: std.mem.Allocator, mtime: std.os.linux.timespec, fmt: [*c]const u8) ![]const u8 { +pub fn formatMtime(alloc: std.mem.Allocator, mtime: std.os.linux.timespec, fmt: [*c]const u8) ![]const u8 { const mtime_str = try alloc.alloc(u8, std.os.linux.PATH_MAX); var tm: c.struct_tm = undefined; _ = c.localtime_r(&mtime.sec, &tm); -- cgit 1.4.1