Пример #1
0
func lsone(c *clnt.Clnt, s string, long bool) {
	st, oserr := c.FStat(normpath(s))
	if oserr != nil {
		fmt.Fprintf(os.Stderr, "error stat: %v\n", oserr)
		return
	}
	if st.Mode&p.DMDIR != 0 {
		file, oserr := c.FOpen(s, p.OREAD)
		if oserr != nil {
			fmt.Fprintf(os.Stderr, "error opening dir: %s\n", oserr)
			return
		}
		defer file.Close()
		for {
			d, oserr := file.Readdir(0)
			if oserr != nil {
				fmt.Fprintf(os.Stderr, "error reading dir: %v\n", oserr)
			}
			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
// Stat the remote file f
func statone(c *clnt.Clnt, f string) {
	fname := normpath(f)

	stat, oserr := c.FStat(fname)
	if oserr != nil {
		fmt.Fprintf(os.Stderr, "error in stat %s: %v\n", fname, oserr)
		return
	}
	fmt.Fprintf(os.Stdout, "%s\n", stat)
}