forked from Elara6331/itd
		
	Directly read/write files from ITD
This commit is contained in:
		
							
								
								
									
										35
									
								
								api/fs.go
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								api/fs.go
									
									
									
									
									
								
							| @@ -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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user