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

Method pasteCopyFilesCheck

filetree/copypaste.go:153–174  ·  view source on GitHub ↗

pasteCopyFilesCheck copies files into given directory node, first checking if any already exist -- if they exist, prompts.

(tdir *Node, md mimedata.Mimes, externalDrop bool, dropFinal func())

Source from the content-addressed store, hash-verified

151// pasteCopyFilesCheck copies files into given directory node,
152// first checking if any already exist -- if they exist, prompts.
153func (fn *Node) pasteCopyFilesCheck(tdir *Node, md mimedata.Mimes, externalDrop bool, dropFinal func()) {
154 existing, _ := fn.pasteCheckExisting(tdir, md, externalDrop)
155 if len(existing) == 0 {
156 fn.pasteCopyFiles(tdir, md, externalDrop)
157 if dropFinal != nil {
158 dropFinal()
159 }
160 return
161 }
162 d := core.NewBody().AddTitle("File(s) Exist in Target Dir, Overwrite?").
163 AddText(fmt.Sprintf("File(s): %v exist, do you want to overwrite?", existing))
164 d.AddBottomBar(func(parent core.Widget) {
165 d.AddCancel(parent)
166 d.AddOK(parent).SetText("Overwrite").OnClick(func(e events.Event) {
167 fn.pasteCopyFiles(tdir, md, externalDrop)
168 if dropFinal != nil {
169 dropFinal()
170 }
171 })
172 })
173 d.RunDialog(fn)
174}
175
176// pasteFiles applies a paste / drop of mime data onto this node.
177// always does a copy of files into / onto target.

Callers 1

pasteFilesMethod · 0.95

Calls 11

pasteCheckExistingMethod · 0.95
pasteCopyFilesMethod · 0.95
NewBodyFunction · 0.92
AddTextMethod · 0.80
AddTitleMethod · 0.80
AddBottomBarMethod · 0.80
AddCancelMethod · 0.80
AddOKMethod · 0.80
RunDialogMethod · 0.80
OnClickMethod · 0.45
SetTextMethod · 0.45

Tested by

no test coverage detected