Directly read/write files from ITD

This commit is contained in:
2021-12-11 22:11:01 -08:00
parent a9ef386883
commit 873df67d1f
4 changed files with 85 additions and 69 deletions

View File

@@ -66,27 +66,26 @@ func (c *Client) ReadDir(path string) ([]types.FileInfo, error) {
return out, nil
}
func (c *Client) ReadFile(path string) (string, error) {
res, err := c.request(types.Request{
Type: types.ReqTypeFS,
Data: types.ReqDataFS{
Type: types.FSTypeRead,
Files: []string{path},
},
})
if err != nil {
return "", err
}
return res.Value.(string), nil
}
func (c *Client) WriteFile(path, data string) error {
func (c *Client) ReadFile(localPath, remotePath string) error {
_, err := c.request(types.Request{
Type: types.ReqTypeFS,
Data: types.ReqDataFS{
Type: types.FSTypeWrite,
Files: []string{path},
Data: data,
Type: types.FSTypeRead,
Files: []string{localPath, remotePath},
},
})
if err != nil {
return err
}
return nil
}
func (c *Client) WriteFile(localPath, remotePath string) error {
_, err := c.request(types.Request{
Type: types.ReqTypeFS,
Data: types.ReqDataFS{
Type: types.FSTypeWrite,
Files: []string{remotePath, localPath},
},
})
if err != nil {