#include <map>
#include <string>
+
+namespace lyx {
+
+namespace support { class FileName; }
+
/**
* Utility to copy a file of a specified format from one place to another.
* This base class simply invokes the command support::copy().
* \returns true if successful.
*/
bool
- copy(std::string const & from, std::string const & to) const
- {
- return do_copy(from, to, to);
- }
+ copy(support::FileName const & from, support::FileName const & to,
+ unsigned long int mode = (unsigned long int)-1) const;
/** Copy file @c from to @c to.
* \see SpecialisedMover::SpecialisedMover() for an explanation of
* \returns true if successful.
*/
bool
- copy(std::string const & from, std::string const & to,
- std::string const & latex) const
+ copy(support::FileName const & from, support::FileName const & to,
+ std::string const & latex,
+ unsigned long int mode = (unsigned long int)-1) const
{
- return do_copy(from, to, latex);
+ return do_copy(from, to, latex, mode);
}
/** Rename file @c from as @c to.
* \returns true if successful.
*/
bool
- rename(std::string const & from, std::string const & to) const
- {
- return do_rename(from, to, to);
- }
+ rename(support::FileName const & from, support::FileName const & to) const;
/** Rename file @c from as @c to.
* \see SpecialisedMover::SpecialisedMover() for an explanation of
* \returns true if successful.
*/
bool
- rename(std::string const & from, std::string const & to,
+ rename(support::FileName const & from, support::FileName const & to,
std::string const & latex) const
{
return do_rename(from, to, latex);
protected:
virtual bool
- do_copy(std::string const & from, std::string const & to,
- std::string const &) const;
+ do_copy(support::FileName const & from, support::FileName const & to,
+ std::string const &, unsigned long int mode) const;
virtual bool
- do_rename(std::string const & from, std::string const & to,
+ do_rename(support::FileName const & from, support::FileName const & to,
std::string const &) const;
};
* Specialisation of the Mover concept that uses an external command
* to copy a file.
*
- * For example, an XFig .fig file can contain references to external
+ * For example, an Xfig .fig file can contain references to external
* picture files. If such a reference has a relative path, then the
* copied .fig file will require a transformation of the picture file
- * reference if it is to be found by XFig.
+ * reference if it is to be found by Xfig.
*/
class SpecialisedMover : public Mover
{
public:
SpecialisedMover() {}
+ virtual ~SpecialisedMover() {}
+
/** @c command should be of the form
* <code>
* python $$s/scripts/fig_copy.py $$i $$o $$l
private:
virtual bool
- do_copy(std::string const & from, std::string const & to,
- std::string const & latex) const;
+ do_copy(support::FileName const & from, support::FileName const & to,
+ std::string const & latex, unsigned long int mode) const;
virtual bool
- do_rename(std::string const & from, std::string const & to,
+ do_rename(support::FileName const & from, support::FileName const & to,
std::string const & latex) const;
std::string command_;
typedef std::map<std::string, SpecialisedMover> SpecialsMap;
public:
- typedef SpecialsMap::const_iterator iterator;
- iterator begin() const { return specials_.begin(); }
- iterator end() const { return specials_.end(); }
+ typedef SpecialsMap::const_iterator const_iterator;
+ const_iterator begin() const { return specials_.begin(); }
+ const_iterator end() const { return specials_.end(); }
private:
Mover default_;
};
-extern Movers movers;
-extern Movers system_movers;
+extern Movers & theMovers();
+/// @c returns the Mover registered for format @c fmt.
+extern Mover const & getMover(std::string const & fmt);
+/** Register a specialised @c command to be used to copy a file
+ * of format @c fmt.
+ */
+extern void setMover(std::string const & fmt, std::string const & command);
+extern Movers & theSystemMovers();
+
+
+} // namespace lyx
#endif // MOVER_H