From e99d7affb0c128fa82722f9b3d79c99b5e5918cd Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 11 Aug 2025 02:52:32 +0900 Subject: container: use absolute for pathname This is simultaneously more efficient and less error-prone. This change caused minor API changes in multiple other packages. Signed-off-by: Ophestra --- ldd/path.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'ldd/path.go') diff --git a/ldd/path.go b/ldd/path.go index 4e41ce74..a0cdb120 100644 --- a/ldd/path.go +++ b/ldd/path.go @@ -1,21 +1,20 @@ package ldd import ( - "path" - "slices" + "hakurei.app/container" ) // Path returns a deterministic, deduplicated slice of absolute directory paths in entries. -func Path(entries []*Entry) []string { - p := make([]string, 0, len(entries)*2) +func Path(entries []*Entry) []*container.Absolute { + p := make([]*container.Absolute, 0, len(entries)*2) for _, entry := range entries { - if path.IsAbs(entry.Path) { - p = append(p, path.Dir(entry.Path)) + if a, err := container.NewAbs(entry.Path); err == nil { + p = append(p, a.Dir()) } - if path.IsAbs(entry.Name) { - p = append(p, path.Dir(entry.Name)) + if a, err := container.NewAbs(entry.Name); err == nil { + p = append(p, a.Dir()) } } - slices.Sort(p) - return slices.Compact(p) + container.SortAbs(p) + return container.CompactAbs(p) } -- cgit v1.3.1