This repository has been archived on 2026-09-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
sqan/path.go
T
2026-08-31 22:25:00 +01:00

28 lines
481 B
Go

package sqan
import "strings"
func ParsePath(rootDir, absPath string) (relPath, relDir, filename, extension string) {
if absPath[0:len(rootDir)] != rootDir {
return
}
relPath = absPath[len(rootDir):]
if i := strings.LastIndexByte(relPath, '/'); i > -1 {
if i > 0 {
relDir = relPath[0:i]
} else {
relDir = "/"
}
filename = relPath[i+1:]
}
if i := strings.LastIndexByte(filename, '.'); i > -1 {
extension = strings.ToLower(filename[i+1:])
}
return
}