#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().
virtual ~Mover() {}
/** Copy file @c from to @c to.
+ * This version should be used to copy files from the original
+ * location to the temporary directory, since @c to and @c latex
+ * would be equal in this case.
+ * \returns true if successful.
+ */
+ bool
+ 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
+ * @c latex.
+ * This version should be used to copy files from the temporary
+ * directory to the export location, since @c to and @c latex may
+ * not be equal in this case.
* \returns true if successful.
*/
bool
- copy(std::string const & from, std::string const & to) 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);
+ return do_copy(from, to, latex, mode);
}
/** Rename file @c from as @c to.
+ * This version should be used to move files from the original
+ * location to the temporary directory, since @c to and @c latex
+ * would be equal in this case.
* \returns true if successful.
*/
bool
- rename(std::string const & from, std::string const & to) const
+ rename(support::FileName const & from, support::FileName const & to) const;
+
+ /** Rename file @c from as @c to.
+ * \see SpecialisedMover::SpecialisedMover() for an explanation of
+ * @c latex.
+ * This version should be used to move files from the temporary
+ * directory to the export location, since @c to and @c latex may
+ * not be equal in this case.
+ * \returns true if successful.
+ */
+ bool
+ rename(support::FileName const & from, support::FileName const & to,
+ std::string const & latex) const
{
- return do_rename(from, to);
+ return do_rename(from, to, latex);
}
protected:
virtual bool
- do_copy(std::string const & from, std::string const & to) 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) const;
+ do_rename(support::FileName const & from, support::FileName const & to,
+ std::string const &) const;
};
* copied .fig file will require a transformation of the picture file
* reference if it is to be found by XFig.
*/
-struct SpecialisedMover : public Mover
+class SpecialisedMover : public Mover
{
+public:
SpecialisedMover() {}
/** @c command should be of the form
* <code>
- * sh $$s/copy_fig.sh $$i $$o
+ * python $$s/scripts/fig_copy.py $$i $$o $$l
* </code>
- * where $$s is a placeholder for the lyx script directory,
+ * where $$s is a placeholder for the lyx support directory,
* $$i is a placeholder for the name of the file to be moved,
- * $$o is a placeholder for the name of the file after moving.
+ * $$o is a placeholder for the name of the file after moving,
+ * $$l is a placeholder for the name of the file after moving,
+ * suitable as argument to a latex include command. This is
+ * either an absolute filename or relative to the master
+ * document.
+ * $$o and $$l can only differ if the file is copied from the
+ * temporary directory to the export location. If it is copied
+ * from the original location to the temporary directory, they
+ * are the same, so $$l may be ommitted in this case.
*/
SpecialisedMover(std::string const & command)
: command_(command) {}
private:
virtual bool
- do_copy(std::string const & from, std::string const & to) 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) const;
+ do_rename(support::FileName const & from, support::FileName const & to,
+ std::string const & latex) const;
std::string command_;
};
extern Movers movers;
extern Movers system_movers;
+
+} // namespace lyx
+
#endif // MOVER_H