+bool Converters::move(string const & fmt,
+ 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;
+
+ Mover const & mover = movers(fmt);
+ bool const moved = copy
+ ? mover.copy(from2, to2)
+ : mover.rename(from2, to2);
+ if (!moved && no_errors) {
+ Alert::error(_("Cannot convert file"),
+ bformat(copy ?
+ _("Could not copy a temporary file from %1$s to %2$s.") :
+ _("Could not move a temporary file from %1$s to %2$s."),
+ from2, to2));
+ no_errors = false;
+ }
+ }
+ return no_errors;