Example #1
0
func recursiveAddFile(space *hdm.Space, n nex.Nex) {
	if n.Type().IsKindOf(nexsys.Directory) && !strings.HasPrefix(nex.String(n), ".") {
		space.NewSurf().Add(n).Expand(2, nexsys.FileSystem)
		for it, x := nex.IterateRels(n, nex.Sub); x != nil; it, x = it.Next() {
			recursiveAddFile(space, x)
		}
	} else if n.Type().IsKindOf(nexsys.File) && isTextFile(n) {
		textFile := nex.Path(n, nexsys.TextFile)
		if _, rn := nex.IterateRels(n, nex.Elevation); rn != nil {
			tlog.Println("elevated node ", textFile)
			// textFile = rn
		}
		space.NewSurf().Add(textFile).Expand(100, nex.TopType)
	}
}
Example #2
0
func value(n nex.Nex) string {
	if n.Type().IsKindOf(nex.ByteUnit) && n.Type().IsKindOf(nex.Amount) {
		if v, err := nex.Fixed(n); err == nil {
			if v < 1024 {
				return fmt.Sprintf("%5d B", v)
			} else if v < 1024*1024 {
				return fmt.Sprintf("%5d KB", v/1024.0)
			} else if v < 1024*1024*1024 {
				return fmt.Sprintf("%5d MB", v/(1024*1024))
			} else if v < 1024*1024*1024*1024 {
				return fmt.Sprintf("%5d GB", v/(1024*1024*1024))
			} else if v < 1024*1024*1024*1024 {
				return fmt.Sprintf("%5d TB", v/(1024*1024*1024*1024))
			}
		}
	}
	return nex.String(n)
}