X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FExporter.cpp;h=a5a153aacdd7e0c069d5c3c279a2a1e5f0b8987c;hb=12c7e7dde3851ad894380fd42ba741dd3d0cbcc7;hp=2c9e4e6e455b1eebac5fa44f53b88ff931e0aea7;hpb=4dc976497f7c384b2e399662ae6a9b19bc98d978;p=lyx.git diff --git a/src/Exporter.cpp b/src/Exporter.cpp index 2c9e4e6e45..a5a153aacd 100644 --- a/src/Exporter.cpp +++ b/src/Exporter.cpp @@ -5,11 +5,11 @@ * * \author unknown * \author Alfredo Braunstein - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * \author Jean Marc Lasgouttes * \author Angus Leeming * \author John Levon - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ @@ -36,18 +36,19 @@ namespace lyx { namespace Alert = frontend::Alert; -/// ask the user what to do if a file already exists +/// Ask the user what to do if a file already exists static int checkOverwrite(FileName const & filename) { if (!filename.exists()) - return 0; + return 1; + docstring text = bformat(_("The file %1$s already exists.\n\n" - "Do you want to overwrite that file?"), - makeDisplayPath(filename.absFilename())); + "Do you want to overwrite that file?"), + makeDisplayPath(filename.absFileName())); return Alert::prompt(_("Overwrite file?"), - text, 0, 2, - _("&Overwrite"), _("Overwrite &all"), - _("&Cancel export")); + text, 0, 3, + _("&Keep file"), _("&Overwrite"), + _("Overwrite &all"), _("&Cancel export")); } @@ -69,15 +70,20 @@ CopyStatus copyFile(string const & format, // overwrite themselves. This check could be changed to // boost::filesystem::equivalent(sourceFile, destFile) if export to // other directories than the document directory is desired. - if (!prefixIs(onlyPath(sourceFile.absFilename()), package().temp_dir().absFilename())) + // Also don't overwrite files that already exist and are identical + // to the source files. + if (!prefixIs(onlyPath(sourceFile.absFileName()), package().temp_dir().absFileName()) + || sourceFile.checksum() == destFile.checksum()) return ret; if (!force) { switch(checkOverwrite(destFile)) { case 0: + return SUCCESS; + case 1: ret = SUCCESS; break; - case 1: + case 2: ret = FORCE; break; default: @@ -86,11 +92,11 @@ CopyStatus copyFile(string const & format, } Mover const & mover = getMover(format); - if (!mover.copy(sourceFile, destFile)) + if (!mover.copy(sourceFile, destFile, latexFile)) Alert::error(_("Couldn't copy file"), bformat(_("Copying %1$s to %2$s failed."), - makeDisplayPath(sourceFile.absFilename()), - makeDisplayPath(destFile.absFilename()))); + makeDisplayPath(sourceFile.absFileName()), + makeDisplayPath(destFile.absFileName()))); return ret; } @@ -115,7 +121,7 @@ void ExportData::addExternalFile(string const & format, { // Make sure that we have every file only once, otherwise copyFile() // would ask several times if it should overwrite a file. - vector & files = externalfiles[format]; + vector & files = externalfiles_[format]; ExportedFile file(sourceName, exportName); if (find(files.begin(), files.end(), file) == files.end()) files.push_back(file); @@ -125,15 +131,15 @@ void ExportData::addExternalFile(string const & format, void ExportData::addExternalFile(string const & format, FileName const & sourceName) { - addExternalFile(format, sourceName, onlyFilename(sourceName.absFilename())); + addExternalFile(format, sourceName, onlyFileName(sourceName.absFileName())); } vector const ExportData::externalFiles(string const & format) const { - FileMap::const_iterator cit = externalfiles.find(format); - if (cit != externalfiles.end()) + FileMap::const_iterator cit = externalfiles_.find(format); + if (cit != externalfiles_.end()) return cit->second; return vector(); }