normalizeDir 规范化目录路径为 "/xxx/" 形式
(path string)
| 217 | |
| 218 | // normalizeDir 规范化目录路径为 "/xxx/" 形式 |
| 219 | func normalizeDir(path string) string { |
| 220 | if path == "" { |
| 221 | return "/" |
| 222 | } |
| 223 | |
| 224 | // 使用 filepath.Clean 处理冗余分隔符,再统一为 Unix 风格 |
| 225 | cleaned := filepath.ToSlash(filepath.Clean(path)) |
| 226 | |
| 227 | if !strings.HasPrefix(cleaned, "/") { |
| 228 | cleaned = "/" + cleaned |
| 229 | } |
| 230 | if !strings.HasSuffix(cleaned, "/") { |
| 231 | cleaned += "/" |
| 232 | } |
| 233 | return cleaned |
| 234 | } |
| 235 | |
| 236 | // resolvePath 将相对名称解析为 memoryPath 下的完整路径 |
| 237 | func (m *Manager) resolvePath(name string) string { |
no outgoing calls
no test coverage detected