Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

33 lines
644 B
Go

package file
import (
"path/filepath"
"strings"
)
// PathInfo 路径信息
type PathInfo struct {
Dir string // 目录
Ext string // 扩展名
FileName string // 没有扩展名的文件名名称
FullFileName string // 文件全名
}
// GetPathInfo 解析路径
// 返回文件,路径,文件名等信息
func GetPathInfo(path string) (pi PathInfo) {
if path == "" {
return
}
if !filepath.IsAbs(path) {
path, _ = filepath.Abs(path)
}
ext := filepath.Ext(path)
dir, name := filepath.Split(path)
pi.Dir = dir
pi.Ext = ext
pi.FileName = strings.TrimRight(name, ext)
pi.FullFileName = name
return
}