MCPcopy Create free account
hub / github.com/cogentcore/core / initFileInfo

Method initFileInfo

filetree/node.go:354–390  ·  view source on GitHub ↗

initFileInfo initializes file info

()

Source from the content-addressed store, hash-verified

352
353// initFileInfo initializes file info
354func (fn *Node) initFileInfo() error {
355 ls, err := os.Lstat(string(fn.Filepath))
356 if err != nil {
357 return err
358 }
359 if ls.Mode()&os.ModeSymlink != 0 {
360 effpath, err := filepath.EvalSymlinks(string(fn.Filepath))
361 if err != nil {
362 // this happens too often for links -- skip
363 // log.Printf("filetree.Node Path: %v could not be opened -- error: %v\n", fn.Filepath, err)
364 return err
365 }
366 fn.Filepath = core.Filename(effpath)
367 }
368
369 err = fn.Info.InitFile(string(fn.Filepath))
370 if err != nil {
371 emsg := fmt.Errorf("filetree.Node InitFileInfo Path %q: Error: %v", fn.Filepath, err)
372 log.Println(emsg)
373 return emsg
374 }
375 repo, rnode := fn.Repo()
376 if repo != nil {
377 if fn.IsDir() {
378 fn.Info.VCS = vcs.Stored // always
379 } else {
380 rstat := rnode.repoFiles.Status(repo, string(fn.Filepath))
381 if rstat != fn.Info.VCS {
382 fn.Info.VCS = rstat
383 fn.NeedsRender()
384 }
385 }
386 } else {
387 fn.Info.VCS = vcs.Stored
388 }
389 return nil
390}
391
392// SelectedFunc runs the given function on all selected nodes in reverse order.
393func (fn *Node) SelectedFunc(fun func(n *Node)) {

Callers 2

InitMethod · 0.95
OpenPathMethod · 0.80

Calls 10

RepoMethod · 0.95
IsDirMethod · 0.95
FilenameTypeAlias · 0.92
LstatMethod · 0.80
ModeMethod · 0.80
InitFileMethod · 0.80
PrintlnMethod · 0.80
NeedsRenderMethod · 0.80
ErrorfMethod · 0.65
StatusMethod · 0.65

Tested by

no test coverage detected