newFile makes a new file in this directory node
(filename string, addToVCS bool)
| 205 | |
| 206 | // newFile makes a new file in this directory node |
| 207 | func (fn *Node) newFile(filename string, addToVCS bool) { //types:add |
| 208 | if fn.isExternal() { |
| 209 | return |
| 210 | } |
| 211 | ppath := string(fn.Filepath) |
| 212 | if !fn.IsDir() { |
| 213 | ppath, _ = filepath.Split(ppath) |
| 214 | } |
| 215 | np := filepath.Join(ppath, filename) |
| 216 | _, err := os.Create(np) |
| 217 | if err != nil { |
| 218 | core.ErrorSnackbar(fn, err) |
| 219 | return |
| 220 | } |
| 221 | if addToVCS { |
| 222 | nfn, ok := fn.FileRoot.FindFile(np) |
| 223 | if ok && nfn.This != fn.FileRoot.This && string(nfn.Filepath) == np { |
| 224 | // todo: this is where it is erroneously adding too many files to vcs! |
| 225 | fmt.Println("Adding new file to VCS:", nfn.Filepath) |
| 226 | core.MessageSnackbar(fn, "Adding new file to VCS: "+fsx.DirAndFile(string(nfn.Filepath))) |
| 227 | nfn.AddToVCS() |
| 228 | } |
| 229 | } |
| 230 | fn.FileRoot.UpdatePath(np) |
| 231 | } |
| 232 | |
| 233 | // makes a new folder in the given selected directory |
| 234 | func (fn *Node) newFolders(foldername string) { //types:add |
no test coverage detected