diff options
| author | Robert Günzler <r@gnzler.io> | 2025-10-03 19:01:17 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2025-10-04 18:41:56 +0200 |
| commit | 17cec3c7f6cb46d8d80c2364eba8296f6dd01ef3 (patch) | |
| tree | a659d8c6ab37de10f4f2eaa623b3d7cd6b47b288 /src/fs.zig | |
| parent | d8ad5e027f60cd8ac86b96eaf4d267e149422025 (diff) | |
| download | site-17cec3c7f6cb46d8d80c2364eba8296f6dd01ef3.tar.gz | |
use canonical duck typing for function names
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '')
| -rw-r--r-- | src/fs.zig | 14 |
1 files changed, 7 insertions, 7 deletions
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); |