MCPcopy Create free account
hub / github.com/astercloud/aster / GlobInfo

Method GlobInfo

pkg/backends/filesystem.go:217–248  ·  view source on GitHub ↗

GlobInfo 实现 BackendProtocol.GlobInfo

(ctx context.Context, pattern, path string)

Source from the content-addressed store, hash-verified

215
216// GlobInfo 实现 BackendProtocol.GlobInfo
217func (b *FilesystemBackend) GlobInfo(ctx context.Context, pattern, path string) ([]FileInfo, error) {
218 if path == "" {
219 path = "."
220 }
221
222 // 使用 SandboxFS 的 Glob 功能
223 searchPattern := filepath.Join(path, pattern)
224 files, err := b.fs.Glob(ctx, searchPattern, &sandbox.GlobOptions{
225 Dot: true,
226 })
227 if err != nil {
228 return nil, fmt.Errorf("glob files: %w", err)
229 }
230
231 var results []FileInfo
232 for _, filePath := range files {
233 stat, err := b.fs.Stat(ctx, filePath)
234 if err != nil {
235 continue
236 }
237
238 results = append(results, FileInfo{
239 Path: filePath,
240 IsDirectory: stat.IsDir,
241 Size: stat.Size,
242 ModifiedTime: stat.ModTime,
243 CreatedTime: stat.ModTime,
244 })
245 }
246
247 return results, nil
248}

Callers

nothing calls this directly

Calls 3

GlobMethod · 0.65
StatMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected