From 1b1460c8d4fa358433c51fd5293fd1c79f32aeff Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Mon, 1 Jul 2024 23:32:54 +0200 Subject: feat: Add pathing to the tree tab --- pkg/u/file.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'pkg/u/file.go') diff --git a/pkg/u/file.go b/pkg/u/file.go index cf86c75..fafe0fb 100644 --- a/pkg/u/file.go +++ b/pkg/u/file.go @@ -4,6 +4,7 @@ import ( "errors" "log/slog" "os" + "path/filepath" ) func FileExist(filename string) bool { @@ -19,3 +20,23 @@ func FileExist(filename string) bool { return false } } + +// This is just a slin wraper to make easier to compose path in the template +type Pathing string + +func Root() Pathing { + return "/" +} + +func (s Pathing) AddPath(p string) Pathing { + return Pathing(filepath.Join(string(s), p)) +} + +func (s Pathing) AddPaths(p []string) Pathing { + f := filepath.Join(p...) + return Pathing(filepath.Join(string(s), f)) +} + +func (s Pathing) Done() string { + return string(s) +} -- cgit v1.2.3