func TestNexFSRoot(t *testing.T) { r := GetFileNex("/").Nex n := nex.Path(r).Nex if n.Value().String() != "/" { t.Error("/ !=", n.Value().String()) } }
func serverMain() { cfgFilePath, err := assets.Locate(cfgFileName) if err != nil { tlog.Fatal("Cannot locate configuration file: ", err) } cfg, err := readConfigFile(cfgFilePath) if err != nil { tlog.Fatal("Cannot read configuration file: ", err) } hdm := hdm.NewHdm(cfg) space := hdm.NewSpace() textFile := nex.Path(nexsys.GetFileNex("main.go"), nexsys.TextFile) space.NewSurf().Add(textFile).Expand(100, nex.TopType) space.NewSurf().Add(parse.Parse("main.go")).Expand(100, nex.TopType) dir := "." ndir := nexsys.GetFileNex(dir) space.NewSurf().Add(ndir).Expand(2, nex.TopType) recursiveAddFile(space, ndir) netServer := netserv.NewServer(hdm.MasterChan()) netServer.Start() }
func TestNexFSFile(t *testing.T) { r := GetFileNex("/").Nex n := nex.Path(r, "usr", "bin", "yes").Nex if n.Value().String() != "yes" { t.Error(n.Value().String(), "!=", "yes") } if n.Type() != File { t.Error(n, " is not File type") } }
func TestNexFSTextFile(t *testing.T) { r := GetFileNex("..").Nex n := nex.Path(r, "README.md").Nex if n.Value().String() != "README.md" { t.Error(n.Value().String(), "!=", "README.md") } elevs := nex.Elevations(n) for it, rn := nex.Iterate(elevs); rn.Err == nil; it, rn = it.Next() { if rn.Nex.Type() == TextFile { return } } t.Error(n, " is not TextFile type") }
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) } }