+ Converter const & conv = converterlist_[edgepath.back()];
+ if (conv.To->dummy())
+ return true;
+
+
+ if (!conv.result_dir.empty()) {
+ to_file = AddName(subst(conv.result_dir, token_base, to_base),
+ subst(conv.result_file,
+ token_base, OnlyFilename(to_base)));
+ if (from_base != to_base) {
+ string from = subst(conv.result_dir,
+ token_base, from_base);
+ string to = subst(conv.result_dir,
+ token_base, to_base);
+ if (!lyx::rename(from, to)) {
+#if USE_BOOST_FORMAT
+ Alert::alert(_("Error while trying to move directory:"),
+ from, boost::io::str(boost::format(_("to %1$s")) % to));
+#else
+ Alert::alert(_("Error while trying to move directory:"),
+ from, _("to ") + to);
+#endif
+ return false;
+ }
+ }
+ return true;
+ } else
+ return move(outfile, to_file, conv.latex);
+}
+
+
+// If from = /path/file.ext and to = /path2/file2.ext2 then this method
+// moves each /path/file*.ext file to /path2/file2*.ext2'
+bool Converters::move(string const & from, string const & to, bool copy)
+{
+ if (from == to)
+ return true;
+
+ bool no_errors = true;
+ string const path = OnlyPath(from);
+ string const base = OnlyFilename(ChangeExtension(from, ""));
+ string const to_base = ChangeExtension(to, "");
+ string const to_extension = GetExtension(to);
+
+ vector<string> files = DirList(OnlyPath(from), GetExtension(from));
+ for (vector<string>::const_iterator it = files.begin();
+ it != files.end(); ++it)
+ if (prefixIs(*it, base)) {
+ string const from2 = path + *it;
+ string to2 = to_base + it->substr(base.length());
+ to2 = ChangeExtension(to2, to_extension);
+ lyxerr[Debug::FILES] << "moving " << from2
+ << " to " << to2 << endl;
+ bool const moved = (copy)
+ ? lyx::copy(from2, to2)
+ : lyx::rename(from2, to2);
+ if (!moved && no_errors) {
+#if USE_BOOST_FORMAT
+ Alert::alert(_("Error while trying to move file:"),
+ from2, boost::io::str(boost::format(_("to %1$s")) % to2));
+#else
+ Alert::alert(_("Error while trying to move file:"),
+ from2, _("to ") + to2);
+#endif
+ no_errors = false;
+ }
+ }
+ return no_errors;