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

Method saveAs

texteditor/diffeditor.go:276–290  ·  view source on GitHub ↗

saveAs saves A or B edits into given file. It checks for an existing file, prompts to overwrite or not.

(ab bool, filename core.Filename)

Source from the content-addressed store, hash-verified

274// saveAs saves A or B edits into given file.
275// It checks for an existing file, prompts to overwrite or not.
276func (dv *DiffEditor) saveAs(ab bool, filename core.Filename) {
277 if !errors.Log1(fsx.FileExists(string(filename))) {
278 dv.saveFile(ab, filename)
279 } else {
280 d := core.NewBody().AddTitle("File Exists, Overwrite?").
281 AddText(fmt.Sprintf("File already exists, overwrite? File: %v", filename))
282 d.AddBottomBar(func(parent core.Widget) {
283 d.AddCancel(parent)
284 d.AddOK(parent).OnClick(func(e events.Event) {
285 dv.saveFile(ab, filename)
286 })
287 })
288 d.RunDialog(dv)
289 }
290}
291
292// saveFile writes A or B edits to file, with no prompting, etc
293func (dv *DiffEditor) saveFile(ab bool, filename core.Filename) error {

Callers 2

saveFileAMethod · 0.95
saveFileBMethod · 0.95

Calls 11

saveFileMethod · 0.95
Log1Function · 0.92
FileExistsFunction · 0.92
NewBodyFunction · 0.92
AddTextMethod · 0.80
AddTitleMethod · 0.80
AddBottomBarMethod · 0.80
AddCancelMethod · 0.80
AddOKMethod · 0.80
RunDialogMethod · 0.80
OnClickMethod · 0.45

Tested by

no test coverage detected