// Print d in DB format func DbFmt(d zx.Dir) string { var b bytes.Buffer fmt.Fprintf(&b, "%-14s", d["path"]) typ := d["type"] if typ == "" { fmt.Fprintf(&b, " -") } else { fmt.Fprintf(&b, " %s", typ) } if d["rm"] != "" { fmt.Fprintf(&b, " GONE") } else { fmt.Fprintf(&b, " 0%o", d.Mode()) } uid := nouid(d["Uid"]) gid := nouid(d["Gid"]) wuid := nouid(d["Wuid"]) fmt.Fprintf(&b, " %-8s %-8s %-8s", uid, gid, wuid) fmt.Fprintf(&b, " %8d", d.Int64("size")) if d["type"] != "d" { fmt.Fprintf(&b, " %d", d.Uint64("mtime")) } if d["err"] != "" { fmt.Fprintf(&b, " %s", d["err"]) } return b.String() }
// Make a new Dir form a zd.Dir func (z *Cfs) newDir(d zx.Dir) *Dir { zd := &Dir{ z: z, d: d, path: d["path"], mode: uint(d.Uint64("mode")&0777), epoch: *z.epoch, } if zd.mode == 0 { zd.mode = 0777 } return zd }