2021-11-23 19:12:16 +00:00
|
|
|
package api
|
|
|
|
|
2022-04-23 00:12:30 +00:00
|
|
|
func (c *Client) Remove(paths ...string) error {
|
2022-05-01 18:36:28 +00:00
|
|
|
return c.client.Call(
|
|
|
|
"FS",
|
2022-04-23 00:12:30 +00:00
|
|
|
"Remove",
|
|
|
|
paths,
|
|
|
|
nil,
|
|
|
|
)
|
2021-11-23 19:12:16 +00:00
|
|
|
}
|
|
|
|
|
2022-04-23 00:12:30 +00:00
|
|
|
func (c *Client) Rename(old, new string) error {
|
2022-05-01 18:36:28 +00:00
|
|
|
return c.client.Call(
|
|
|
|
"FS",
|
|
|
|
"Rename",
|
2022-04-23 00:12:30 +00:00
|
|
|
[2]string{old, new},
|
|
|
|
nil,
|
|
|
|
)
|
2021-11-23 19:12:16 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 21:35:18 +00:00
|
|
|
func (c *Client) Mkdir(paths ...string) error {
|
2022-05-01 18:36:28 +00:00
|
|
|
return c.client.Call(
|
|
|
|
"FS",
|
2022-04-23 00:12:30 +00:00
|
|
|
"Mkdir",
|
|
|
|
paths,
|
|
|
|
nil,
|
|
|
|
)
|
2021-11-23 19:12:16 +00:00
|
|
|
}
|
|
|
|
|
2022-04-23 00:12:30 +00:00
|
|
|
func (c *Client) ReadDir(dir string) (out []FileInfo, err error) {
|
2022-05-01 18:36:28 +00:00
|
|
|
err = c.client.Call(
|
|
|
|
"FS",
|
2022-04-23 00:12:30 +00:00
|
|
|
"ReadDir",
|
|
|
|
dir,
|
|
|
|
&out,
|
|
|
|
)
|
|
|
|
return
|
2021-11-23 19:12:16 +00:00
|
|
|
}
|
|
|
|
|
2022-04-23 00:12:30 +00:00
|
|
|
func (c *Client) Upload(dst, src string) (chan FSTransferProgress, error) {
|
2022-05-01 18:36:28 +00:00
|
|
|
progressCh := make(chan FSTransferProgress, 5)
|
|
|
|
err := c.client.Call(
|
|
|
|
"FS",
|
2022-04-23 00:12:30 +00:00
|
|
|
"Upload",
|
|
|
|
[2]string{dst, src},
|
2022-05-01 18:36:28 +00:00
|
|
|
progressCh,
|
2022-04-23 00:12:30 +00:00
|
|
|
)
|
2021-11-23 19:12:16 +00:00
|
|
|
if err != nil {
|
2021-12-13 01:08:48 +00:00
|
|
|
return nil, err
|
2021-11-23 19:12:16 +00:00
|
|
|
}
|
2021-12-13 01:08:48 +00:00
|
|
|
|
2022-04-23 00:12:30 +00:00
|
|
|
return progressCh, nil
|
|
|
|
}
|
2021-12-13 01:08:48 +00:00
|
|
|
|
2022-04-23 00:12:30 +00:00
|
|
|
func (c *Client) Download(dst, src string) (chan FSTransferProgress, error) {
|
2022-05-01 18:36:28 +00:00
|
|
|
progressCh := make(chan FSTransferProgress, 5)
|
|
|
|
err := c.client.Call(
|
|
|
|
"FS",
|
2022-04-23 00:12:30 +00:00
|
|
|
"Download",
|
|
|
|
[2]string{dst, src},
|
2022-05-01 18:36:28 +00:00
|
|
|
progressCh,
|
2022-04-23 00:12:30 +00:00
|
|
|
)
|
2021-11-23 19:12:16 +00:00
|
|
|
if err != nil {
|
2021-12-13 01:08:48 +00:00
|
|
|
return nil, err
|
2021-11-23 19:12:16 +00:00
|
|
|
}
|
2021-12-13 01:08:48 +00:00
|
|
|
|
2022-04-23 00:12:30 +00:00
|
|
|
return progressCh, nil
|
2021-11-23 19:12:16 +00:00
|
|
|
}
|