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

Method Stat

pkg/sandbox/cloud/volcengine.go:270–297  ·  view source on GitHub ↗

Stat 获取文件信息

(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

268
269// Stat 获取文件信息
270func (vfs *VolcengineFS) Stat(ctx context.Context, path string) (sandbox.FileInfo, error) {
271 absPath := vfs.absPath(path)
272
273 result, err := vfs.mcpClient.CallTool(ctx, "computer_stat_file", map[string]any{
274 "session_id": vfs.sessionID,
275 "path": absPath,
276 })
277 if err != nil {
278 return sandbox.FileInfo{}, fmt.Errorf("stat file: %w", err)
279 }
280
281 var fileInfo struct {
282 Path string `json:"path"`
283 IsDir bool `json:"is_dir"`
284 Size int64 `json:"size"`
285 MTime int64 `json:"mtime"`
286 }
287 if err := json.Unmarshal(result, &fileInfo); err != nil {
288 return sandbox.FileInfo{}, fmt.Errorf("parse file info: %w", err)
289 }
290
291 return sandbox.FileInfo{
292 Path: fileInfo.Path,
293 IsDir: fileInfo.IsDir,
294 Size: fileInfo.Size,
295 ModTime: time.Unix(fileInfo.MTime, 0),
296 }, nil
297}
298
299// Glob 匹配文件
300func (vfs *VolcengineFS) Glob(ctx context.Context, pattern string, opts *sandbox.GlobOptions) ([]string, error) {

Callers

nothing calls this directly

Calls 2

absPathMethod · 0.95
CallToolMethod · 0.45

Tested by

no test coverage detected