X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FExporter.cpp;h=073842f2806213c9deeec12add2b61ba351a7c6f;hb=eea4ef9b6e8c103b8d77fb456214a116c68f58a7;hp=b1343e2c485cba3d0b4a7f73d1bd09e522702b4a;hpb=62ca7f3ae55ad2e0c395cb554d71afab87de1ee3;p=lyx.git diff --git a/src/Exporter.cpp b/src/Exporter.cpp index b1343e2c48..073842f280 100644 --- a/src/Exporter.cpp +++ b/src/Exporter.cpp @@ -47,13 +47,15 @@ static int checkOverwrite(FileName const & filename) makeDisplayPath(filename.absFileName())); return Alert::prompt(_("Overwrite file?"), text, 0, 3, - _("&Overwrite"), _("Overwrite &all"), - _("&Keep file"), _("&Cancel export")); + _("&Keep file"), _("&Overwrite"), + _("Overwrite &all"), _("&Cancel export")); } /** copy file \p sourceFile to \p destFile. If \p force is false, the user - * will be asked before existing files are overwritten. + * will be asked before existing files are overwritten. If \p only_tmp + * is true, then only copy files that are in our tmp dir (to avoid other files + * overwriting themselves). * \return * - SUCCESS if this file got copied * - FORCE if subsequent calls should not ask for confirmation before @@ -62,30 +64,29 @@ static int checkOverwrite(FileName const & filename) */ CopyStatus copyFile(string const & format, FileName const & sourceFile, FileName const & destFile, - string const & latexFile, bool force) + string const & latexFile, bool force, bool only_tmp) { CopyStatus ret = force ? FORCE : SUCCESS; - // Only copy files that are in our tmp dir, all other files would - // overwrite themselves. This check could be changed to + // This check could be changed to // boost::filesystem::equivalent(sourceFile, destFile) if export to // other directories than the document directory is desired. // Also don't overwrite files that already exist and are identical // to the source files. - if (!prefixIs(onlyPath(sourceFile.absFileName()), package().temp_dir().absFileName()) + if ((only_tmp && !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; - case 2: - return SUCCESS; default: return CANCEL; } @@ -131,7 +132,7 @@ 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())); }