示例#1
0
文件: cl.go 项目: zxpbenson/rog-go
func lsone(ns *g9pc.Ns, s string, long bool) {
	st, err := ns.Stat(s)
	if err != nil {
		fmt.Fprintf(os.Stderr, "error stat: %s\n", err)
		return
	}
	if st.Mode&g9p.DMDIR != 0 {
		file, err := ns.Open(s, g9p.OREAD)
		if err != nil {
			fmt.Fprintf(os.Stderr, "error opening dir: %s\n", err)
			return
		}
		defer file.Close()
		for {
			d, err := file.Dirread()
			if err != nil && err != io.EOF {
				fmt.Fprintf(os.Stderr, "error reading dir: %s\n", err)
			}
			if d == nil || len(d) == 0 {
				break
			}
			for _, dir := range d {
				if long {
					fmt.Fprintf(os.Stdout, "%s\n", dirtostr(dir))
				} else {
					os.Stdout.WriteString(dir.Name + "\n")
				}
			}
		}
	} else {
		fmt.Fprintf(os.Stdout, "%s\n", dirtostr(st))
	}
}
示例#2
0
文件: cl.go 项目: zxpbenson/rog-go
// Stat the remote file f
func statone(ns *g9pc.Ns, f string) {
	stat, err := ns.Stat(f)
	if err != nil {
		fmt.Fprintf(os.Stderr, "error in stat %s: %s\n", f, err)
		return
	}
	fmt.Fprintf(os.Stdout, "%v\n", stat)
}