3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
15 #include "support/filetools.h"
16 #include "support/lstrings.h"
17 #include "support/lyxlib.h"
18 #include "support/systemcall.h"
31 bool Mover::do_copy(string const & from, string const & to,
34 return support::copy(from, to);
38 bool Mover::do_rename(string const & from, string const & to,
41 return support::rename(from, to);
45 bool SpecialisedMover::do_copy(string const & from, string const & to,
46 string const & latex) const
49 return Mover::do_copy(from, to, latex);
51 string command = support::libScriptSearch(command_);
52 command = support::subst(command, "$$i", from);
53 command = support::subst(command, "$$o", to);
54 command = support::subst(command, "$$l", latex);
56 support::Systemcall one;
57 return one.startscript(support::Systemcall::Wait, command) == 0;
61 bool SpecialisedMover::do_rename(string const & from, string const & to,
62 string const & latex) const
65 return Mover::do_rename(from, to, latex);
67 if (!do_copy(from, to, latex))
69 return support::unlink(from) == 0;
73 void Movers::set(string const & fmt, string const & command)
75 specials_[fmt] = SpecialisedMover(command);
79 Mover const & Movers::operator()(string const & fmt) const
81 SpecialsMap::const_iterator const it = specials_.find(fmt);
82 return (it == specials_.end()) ? default_ : it->second;
86 string const Movers::command(string const & fmt) const
88 SpecialsMap::const_iterator const it = specials_.find(fmt);
89 return (it == specials_.end()) ? string() : it->second.command();