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

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