go-scm/internal/ax/filepathx/filepathx.go
Virgil a0fac1341b
Some checks failed
Security Scan / security (push) Failing after 10s
Test / test (push) Successful in 2m11s
chore(ax): add usage docs to exported APIs
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 14:11:15 +00:00

54 lines
984 B
Go

// SPDX-License-Identifier: EUPL-1.2
package filepathx
import (
"path"
"syscall"
)
// Separator mirrors filepath.Separator for Unix-style Core paths.
const Separator = '/'
// Abs mirrors filepath.Abs for the paths used in this repo.
// Usage: Abs(...)
func Abs(p string) (string, error) {
if path.IsAbs(p) {
return path.Clean(p), nil
}
cwd, err := syscall.Getwd()
if err != nil {
return "", err
}
return path.Clean(path.Join(cwd, p)), nil
}
// Base mirrors filepath.Base.
// Usage: Base(...)
func Base(p string) string {
return path.Base(p)
}
// Clean mirrors filepath.Clean.
// Usage: Clean(...)
func Clean(p string) string {
return path.Clean(p)
}
// Dir mirrors filepath.Dir.
// Usage: Dir(...)
func Dir(p string) string {
return path.Dir(p)
}
// Ext mirrors filepath.Ext.
// Usage: Ext(...)
func Ext(p string) string {
return path.Ext(p)
}
// Join mirrors filepath.Join.
// Usage: Join(...)
func Join(elem ...string) string {
return path.Join(elem...)
}