]> git.lyx.org Git - lyx.git/blobdiff - src/exporter.C
Implement os::current_root for native Win32 builds.
[lyx.git] / src / exporter.C
index 23ada4a7891c4a9813aa52e6c2252b10f983008d..ba090ea8af942df6bf915f4985e564bea679da86 100644 (file)
@@ -25,6 +25,7 @@
 #include "format.h"
 #include "gettext.h"
 #include "lyxrc.h"
+#include "mover.h"
 #include "output_plaintext.h"
 #include "outputparams.h"
 #include "frontends/Alert.h"
@@ -86,14 +87,15 @@ enum CopyStatus {
 
 /** copy file \p sourceFile to \p destFile. If \p force is false, the user
  *  will be asked before existing files are overwritten.
- *  \return 
+ *  \return
  *  - SUCCESS if this file got copied
  *  - FORCE   if subsequent calls should not ask for confirmation before
  *            overwriting files anymore.
  *  - CANCEL  if the export should be cancelled
  */
-CopyStatus copyFile(string const & sourceFile, string const & destFile,
-                   bool force)
+CopyStatus copyFile(string const & format,
+                    string const & sourceFile, string const & destFile,
+                    string const & latexFile, bool force)
 {
        CopyStatus ret = force ? FORCE : SUCCESS;
 
@@ -117,7 +119,8 @@ CopyStatus copyFile(string const & sourceFile, string const & destFile,
                }
        }
 
-       if (!lyx::support::copy(sourceFile, destFile))
+       Mover const & mover = movers(format);
+       if (!mover.copy(sourceFile, destFile, latexFile))
                Alert::error(_("Couldn't copy file"),
                             bformat(_("Copying %1$s to %2$s failed."),
                                     MakeDisplayPath(sourceFile),
@@ -203,15 +206,19 @@ bool Exporter::Export(Buffer * buffer, string const & format,
                string const dest = OnlyPath(result_file);
                CopyStatus status = SUCCESS;
                for (vector<ExportedFile>::const_iterator it = files.begin();
-                               it != files.end() && status != CANCEL; ++it)
-                       status = copyFile(it->sourceName,
+                               it != files.end() && status != CANCEL; ++it) {
+                       string const fmt =
+                               formats.getFormatFromFile(it->sourceName);
+                       status = copyFile(fmt, it->sourceName,
                                          MakeAbsPath(it->exportName, dest),
-                                         status == FORCE);
+                                         it->exportName, status == FORCE);
+               }
                if (status == CANCEL) {
                        buffer->message(_("Document export cancelled."));
                } else {
                        // Finally copy the main file
-                       status = copyFile(tmp_result_file, result_file,
+                       status = copyFile(format, tmp_result_file,
+                                         result_file, result_file,
                                          status == FORCE);
                        buffer->message(bformat(_("Document exported as %1$s"
                                                  "to file `%2$s'"),
@@ -281,8 +288,8 @@ bool operator==(ExportedFile const & f1, ExportedFile const & f2)
 
 
 void ExportData::addExternalFile(string const & format,
-                                 string const & sourceName,
-                                 string const & exportName)
+                                string const & sourceName,
+                                string const & exportName)
 {
        BOOST_ASSERT(lyx::support::AbsolutePath(sourceName));
 
@@ -296,7 +303,7 @@ void ExportData::addExternalFile(string const & format,
 
 
 void ExportData::addExternalFile(string const & format,
-                                 string const & sourceName)
+                                string const & sourceName)
 {
        addExternalFile(format, sourceName, OnlyFilename(sourceName));
 }