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.
13 #include "support/filetools.h"
14 #include "support/lstrings.h"
15 #include "support/lyxlib.h"
16 #include "support/systemcall.h"
20 using std::ostringstream;
23 namespace support = lyx::support;
29 bool Mover::do_copy(string const & from, string const & to) const
31 return support::copy(from, to);
35 bool Mover::do_rename(string const & from, string const & to) const
37 return support::rename(from, to);
41 bool SpecialisedMover::do_copy(string const & from, string const & to) const
44 return Mover::do_copy(from, to);
46 string command = support::LibScriptSearch(command_);
47 command = support::subst(command, "$$i", from);
48 command = support::subst(command, "$$o", to);
50 support::Systemcall one;
51 return one.startscript(support::Systemcall::Wait, command) == 0;
55 bool SpecialisedMover::do_rename(string const & from, string const & to) const
58 return Mover::do_rename(from, to);
60 if (!do_copy(from, to))
62 return support::unlink(from) == 0;
66 void Movers::set(string const & fmt, string const & command)
68 specials_[fmt] = SpecialisedMover(command);
72 Mover const & Movers::operator()(string const & fmt) const
74 SpecialsMap::const_iterator const it = specials_.find(fmt);
75 return (it == specials_.end()) ? default_ : it->second;
79 string const Movers::command(string const & fmt) const
81 SpecialsMap::const_iterator const it = specials_.find(fmt);
82 return (it == specials_.end()) ? string() : it->second.command();