]> git.lyx.org Git - features.git/commitdiff
Bug fix of the day: 2963 (print to file overwrites files without warning)
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 1 Feb 2007 12:55:57 +0000 (12:55 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 1 Feb 2007 12:55:57 +0000 (12:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17002 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxfunc.C

index 5358c2412f39e086f3bf6448b7f08cbe876bab68..99db51a021004283b753ccc15435461b4a8b68c2 100644 (file)
@@ -1055,9 +1055,20 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                        } else {
                                // case 1: print to a file
+                               FileName const filename(makeAbsPath(target_name, path));
+                               if (fs::exists(filename.toFilesystemEncoding())) {
+                                       docstring text = bformat(
+                                               _("The file %1$s already exists.\n\n"
+                                                 "Do you want to over-write that file?"),
+                                               makeDisplayPath(filename.absFilename()));
+                                       if (Alert::prompt(_("Over-write file?"),
+                                           text, 0, 1, _("&Over-write"), _("&Cancel")) != 0) {
+                                               showPrintError(buffer->fileName());
+                                               break;
+                                       }
+                               }
                                command += lyxrc.print_to_file
-                                       + quoteName(makeAbsPath(target_name,
-                                                               path).toFilesystemEncoding())
+                                       + quoteName(filename.toFilesystemEncoding())
                                        + ' '
                                        + quoteName(dviname);
                                res = one.startscript(Systemcall::DontWait,