Пример #1
0
func cd(root, cwd client.Fid, cmdline string) (client.Fid, error) {
	path, absolute := parsepath(cmdline)

	f := cwd
	if absolute {
		f = root
	}

	f, qs, err := f.Walk(path)
	if err != nil {
		return cwd, err
	}

	if qs[len(qs)-1].Type != qp.QTDIR {
		return cwd, errors.New("not a directory")
	}

	cwd.Clunk()
	return f, nil
}