itd/api/fs.go

69 lines
1.0 KiB
Go
Raw Normal View History

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 {
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 {
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
}
func (c *Client) Mkdir(paths ...string) error {
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) {
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) {
progressCh := make(chan FSTransferProgress, 5)
err := c.client.Call(
"FS",
2022-04-23 00:12:30 +00:00
"Upload",
[2]string{dst, src},
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) {
progressCh := make(chan FSTransferProgress, 5)
err := c.client.Call(
"FS",
2022-04-23 00:12:30 +00:00
"Download",
[2]string{dst, src},
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
}