1 Star 0 Fork 0

zx / hdfs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
rename.go 799 Bytes
一键复制 编辑 原始数据 按行查看 历史
package hdfs
import (
"os"
hdfs "github.com/colinmarc/hdfs/protocol/hadoop_hdfs"
"github.com/colinmarc/hdfs/rpc"
"github.com/golang/protobuf/proto"
)
// Rename renames (moves) a file.
func (c *Client) Rename(oldpath, newpath string) error {
_, err := c.getFileInfo(newpath)
if err != nil && !os.IsNotExist(err) {
return &os.PathError{"rename", newpath, err}
}
req := &hdfs.Rename2RequestProto{
Src: proto.String(oldpath),
Dst: proto.String(newpath),
OverwriteDest: proto.Bool(true),
}
resp := &hdfs.Rename2ResponseProto{}
err = c.namenode.Execute("rename2", req, resp)
if err != nil {
if nnErr, ok := err.(*rpc.NamenodeError); ok {
err = interpretException(nnErr.Exception, err)
}
return &os.PathError{"rename", oldpath, err}
}
return nil
}
Go
1
https://gitee.com/z_matrix/hdfs.git
git@gitee.com:z_matrix/hdfs.git
z_matrix
hdfs
hdfs
v1.1.3

搜索帮助