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

Method copyFileToDir

filetree/file.go:264–285  ·  view source on GitHub ↗

copyFileToDir copies given file path into node that is a directory. This does NOT check for overwriting -- that must be done at higher level!

(filename string, perm os.FileMode)

Source from the content-addressed store, hash-verified

262// copyFileToDir copies given file path into node that is a directory.
263// This does NOT check for overwriting -- that must be done at higher level!
264func (fn *Node) copyFileToDir(filename string, perm os.FileMode) {
265 if fn.isExternal() {
266 return
267 }
268 ppath := string(fn.Filepath)
269 sfn := filepath.Base(filename)
270 tpath := filepath.Join(ppath, sfn)
271 fileinfo.CopyFile(tpath, filename, perm)
272 fn.FileRoot.UpdatePath(ppath)
273 ofn, ok := fn.FileRoot.FindFile(filename)
274 if ok && ofn.Info.VCS >= vcs.Stored {
275 nfn, ok := fn.FileRoot.FindFile(tpath)
276 if ok && nfn.This != fn.FileRoot.This {
277 if string(nfn.Filepath) != tpath {
278 fmt.Printf("error: nfn.FPath != tpath; %q != %q, see bug #453\n", nfn.Filepath, tpath)
279 } else {
280 nfn.AddToVCS() // todo: this sometimes is not just tpath! See bug #453
281 }
282 nfn.Update()
283 }
284 }
285}
286
287// Shows file information about selected file(s)
288func (fn *Node) showFileInfo() { //types:add

Callers 2

pasteCopyFilesMethod · 0.80
pasteFilesMethod · 0.80

Calls 8

isExternalMethod · 0.95
CopyFileFunction · 0.92
UpdatePathMethod · 0.80
FindFileMethod · 0.80
AddToVCSMethod · 0.80
BaseMethod · 0.65
UpdateMethod · 0.65
PrintfMethod · 0.45

Tested by

no test coverage detected