pasteCheckExisting checks for existing files in target node directory if that is non-nil (otherwise just uses absolute path), and returns list of existing and node for last one if exists.
(tfn *Node, md mimedata.Mimes, externalDrop bool)
| 77 | // that is non-nil (otherwise just uses absolute path), and returns list of existing |
| 78 | // and node for last one if exists. |
| 79 | func (fn *Node) pasteCheckExisting(tfn *Node, md mimedata.Mimes, externalDrop bool) ([]string, *Node) { |
| 80 | froot := fn.FileRoot |
| 81 | tpath := "" |
| 82 | if tfn != nil { |
| 83 | tpath = string(tfn.Filepath) |
| 84 | } |
| 85 | nf := len(md) |
| 86 | if !externalDrop { |
| 87 | nf /= 3 |
| 88 | } |
| 89 | var sfn *Node |
| 90 | var existing []string |
| 91 | for i := 0; i < nf; i++ { |
| 92 | var d *mimedata.Data |
| 93 | if !externalDrop { |
| 94 | d = md[i*3+1] |
| 95 | npath := string(md[i*3].Data) |
| 96 | sfni := froot.FindPath(npath) |
| 97 | if sfni != nil { |
| 98 | sfn = AsNode(sfni) |
| 99 | } |
| 100 | } else { |
| 101 | d = md[i] // just a list |
| 102 | } |
| 103 | if d.Type != fileinfo.TextPlain { |
| 104 | continue |
| 105 | } |
| 106 | path := string(d.Data) |
| 107 | path = strings.TrimPrefix(path, "file://") |
| 108 | if tfn != nil { |
| 109 | _, fnm := filepath.Split(path) |
| 110 | path = filepath.Join(tpath, fnm) |
| 111 | } |
| 112 | if errors.Log1(fsx.FileExists(path)) { |
| 113 | existing = append(existing, path) |
| 114 | } |
| 115 | } |
| 116 | return existing, sfn |
| 117 | } |
| 118 | |
| 119 | // pasteCopyFiles copies files in given data into given target directory |
| 120 | func (fn *Node) pasteCopyFiles(tdir *Node, md mimedata.Mimes, externalDrop bool) { |
no test coverage detected