MCPcopy Create free account
hub / github.com/53AI/53AIHub / splitPathLevels

Function splitPathLevels

api/model/file.go:1776–1793  ·  view source on GitHub ↗

splitPathLevels 拆解文件路径为所有父级目录路径 示例:/1/2/3/file.md -> ["/1", "/1/2", "/1/2/3"]

(filePath string)

Source from the content-addressed store, hash-verified

1774// splitPathLevels 拆解文件路径为所有父级目录路径
1775// 示例:/1/2/3/file.md -> ["/1", "/1/2", "/1/2/3"]
1776func splitPathLevels(filePath string) []string {
1777 if filePath == "" || filePath == "/" {
1778 return []string{}
1779 }
1780
1781 // 移除开头和结尾的斜杠,然后分割
1782 cleanPath := strings.Trim(filePath, "/")
1783 parts := strings.Split(cleanPath, "/")
1784
1785 var levels []string
1786 // 只处理目录部分,排除文件名
1787 for i := 1; i < len(parts); i++ {
1788 level := "/" + strings.Join(parts[:i], "/")
1789 levels = append(levels, level)
1790 }
1791
1792 return levels
1793}
1794
1795// CleanupVectorDataForFile 清理文件的向量数据,可以被独立调用
1796func CleanupVectorDataForFile(eid int64, fileID int64) error {

Callers 1

GetFileWithParentsByIDFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected