Write 实现 BackendProtocol.Write
(ctx context.Context, path, content string)
| 96 | |
| 97 | // Write 实现 BackendProtocol.Write |
| 98 | func (b *FilesystemBackend) Write(ctx context.Context, path, content string) (*WriteResult, error) { |
| 99 | // 使用 SandboxFS 写入文件 |
| 100 | if err := b.fs.Write(ctx, path, content); err != nil { |
| 101 | return nil, err |
| 102 | } |
| 103 | |
| 104 | return &WriteResult{ |
| 105 | Error: "", // 空字符串表示成功 |
| 106 | Path: path, |
| 107 | BytesWritten: int64(len(content)), |
| 108 | FilesUpdate: nil, // FilesystemBackend 不需要返回状态更新 |
| 109 | }, nil |
| 110 | } |
| 111 | |
| 112 | // Edit 实现 BackendProtocol.Edit |
| 113 | func (b *FilesystemBackend) Edit(ctx context.Context, path, oldStr, newStr string, replaceAll bool) (*EditResult, error) { |