Stat 获取文件信息
(ctx context.Context, path string)
| 268 | |
| 269 | // Stat 获取文件信息 |
| 270 | func (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 匹配文件 |
| 300 | func (vfs *VolcengineFS) Glob(ctx context.Context, pattern string, opts *sandbox.GlobOptions) ([]string, error) { |