╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Files.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
843 844 // the "a:" link for the files route at `dir`, pinned to the listing's ref. 845 fn dirLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, dir: []const u8) ![]const u8 { 846 const route = ui.RoutablePage.repoFilesRoute(data.identity, data.ref_or_oid, data.ref_or_oid_value, dir, 0) orelse return error.RouteTooLong; 847 const url = try route.urlAlloc(page_arena); 848 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 849 } 850 851 // `dir`/`name`, or just `name` at the root. 852 pub fn childDir(arena: std.mem.Allocator, dir: []const u8, name: []const u8) ![]const u8 { 853 return if (dir.len == 0) name else std.fmt.allocPrint(arena, "{s}/{s}", .{ dir, name }); 854 } 855 856 // `dir` with its last segment removed ("" when `dir` has a single segment). 857 fn parentDir(dir: []const u8) []const u8 { 858 const slash = std.mem.lastIndexOfScalar(u8, dir, '/') orelse return ""; 859 return dir[0..slash]; 860 } 861