示例#1
0
文件: client.go 项目: shaladdle/goaaw
func (fs *Client) Mkdir(fpath string) error {
	var cErr rpc.StrError

	err := fs.rpc.Call("RemoteFS.Mkdir", fpath, &cErr)
	if err != nil {
		return fmt.Errorf("rpc error: %v", err)
	}

	if !cErr.IsNil() {
		return cErr
	}

	return nil
}
示例#2
0
文件: client.go 项目: shaladdle/goaaw
func (fs *Client) Create(fpath string) (io.WriteCloser, error) {
	var cErr rpc.StrError

	f, err := fs.rpc.CallWrite("RemoteFS.Create", fpath, &cErr)
	if err != nil {
		return nil, fmt.Errorf("rpc error: %v", err)
	}

	if !cErr.IsNil() {
		return nil, cErr
	}

	return f, nil
}
示例#3
0
文件: client.go 项目: shaladdle/goaaw
func (fs *Client) Open(fpath string) (io.ReadCloser, error) {
	var cErr rpc.StrError

	f, err := fs.rpc.CallRead("RemoteFS.Open", fpath, &cErr)
	if err != nil {
		return nil, fmt.Errorf("rpc error: %v", err)
	}

	if !cErr.IsNil() {
		return nil, cErr
	}

	return closeWrapper{f}, nil
}
示例#4
0
文件: client.go 项目: shaladdle/goaaw
func (fs *Client) Stat(fpath string) (os.FileInfo, error) {
	var (
		cErr rpc.StrError
		info util.FileInfo
	)

	err := fs.rpc.Call("RemoteFS.Stat", fpath, &info, &cErr)
	if err != nil {
		return nil, fmt.Errorf("rpc error: %v", err)
	}

	if !cErr.IsNil() {
		return nil, cErr
	}

	return info, nil
}
示例#5
0
文件: client.go 项目: shaladdle/goaaw
func (fs *Client) GetFiles(fpath string) ([]os.FileInfo, error) {
	var (
		cErr  rpc.StrError
		infos []util.FileInfo
	)

	err := fs.rpc.Call("RemoteFS.GetFiles", fpath, &infos, &cErr)
	if err != nil {
		return nil, fmt.Errorf("rpc error: %v", err)
	}

	if !cErr.IsNil() {
		return nil, cErr
	}

	ret := make([]os.FileInfo, len(infos))
	for i, info := range infos {
		ret[i] = info
	}

	return ret, nil
}