aboutsummaryrefslogtreecommitdiffhomepage
path: root/ldd/path.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-11 02:52:32 +0900
committerOphestra <cat@gensokyo.uk>2025-08-11 04:56:42 +0900
commite99d7affb0c128fa82722f9b3d79c99b5e5918cd (patch)
tree387e08d6c4363d8b9e0462f069c140fbdb15c917 /ldd/path.go
parent41ac2be9658b49c68cb793f3a6f0c5932d82e1c2 (diff)
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 <cat@gensokyo.uk>
Diffstat (limited to 'ldd/path.go')
-rw-r--r--ldd/path.go19
1 files changed, 9 insertions, 10 deletions
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)
}