- // Same name as we have already?
- if (!buffer->isUnnamed() && fname == oldname) {
- if (!Alert::askQuestion(_("Same name as document already has:"),
- MakeDisplayPath(fname, 50),
- _("Save anyway?")))
- return false;
- // Falls through to name change and save
- }
- // No, but do we have another file with this name open?
- else if (!buffer->isUnnamed() && bufferlist.exists(fname)) {
- if (Alert::askQuestion(_("Another document with same name open!"),
- MakeDisplayPath(fname, 50),
- _("Replace with current document?")))
- {
- bufferlist.close(bufferlist.getBuffer(fname));
-
- // Ok, change the name of the buffer, but don't save!
- buffer->setFileName(fname);
- buffer->markDirty();
-
- ShowMessage(buffer, _("Document renamed to '"),
- MakeDisplayPath(fname), _("', but not saved..."));
- }
- return false;
- } // Check whether the file exists
- else {
- FileInfo const myfile(fname);
- if (myfile.isOK() && !Alert::askQuestion(_("Document already exists:"),
- MakeDisplayPath(fname, 50),
- _("Replace file?")))
+ if (fs::exists(fname)) {
+ docstring const file = makeDisplayPath(fname, 30);
+ docstring text = bformat(_("The document %1$s already exists.\n\n"
+ "Do you want to over-write that document?"), file);
+ int const ret = Alert::prompt(_("Over-write document?"),
+ text, 0, 1, _("&Over-write"), _("&Cancel"));
+
+ if (ret == 1)