代码拉取完成,页面将自动刷新
package hdfs
import (
"errors"
"os"
hdfs "github.com/colinmarc/hdfs/v2/internal/protocol/hadoop_hdfs"
"github.com/golang/protobuf/proto"
)
// Remove removes the named file or (empty) directory.
func (c *Client) Remove(name string) error {
return delete(c, name, false)
}
// RemoveAll removes path and any children it contains. It removes everything it
// can but returns the first error it encounters. If the path does not exist,
// RemoveAll returns nil (no error).
func (c *Client) RemoveAll(name string) error {
err := delete(c, name, true)
if os.IsNotExist(err) {
return nil
}
return err
}
func delete(c *Client, name string, recursive bool) error {
_, err := c.getFileInfo(name)
if err != nil {
return &os.PathError{"remove", name, err}
}
req := &hdfs.DeleteRequestProto{
Src: proto.String(name),
Recursive: proto.Bool(recursive),
}
resp := &hdfs.DeleteResponseProto{}
err = c.namenode.Execute("delete", req, resp)
if err != nil {
return &os.PathError{"remove", name, interpretException(err)}
} else if resp.Result == nil {
return &os.PathError{
"remove",
name,
errors.New("unexpected empty response"),
}
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。