4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
19 * Utility to copy a file of a specified format from one place to another.
20 * This base class simply invokes the command support::copy().
27 /** Copy file @c from to @c to.
28 * \returns true if successful.
31 copy(std::string const & from, std::string const & to) const
33 return do_copy(from, to);
36 /** Rename file @c from as @c to.
37 * \returns true if successful.
40 rename(std::string const & from, std::string const & to) const
42 return do_rename(from, to);
47 do_copy(std::string const & from, std::string const & to) const;
50 do_rename(std::string const & from, std::string const & to) const;
55 * Specialisation of the Mover concept that uses an external command
58 * For example, an XFig .fig file can contain references to external
59 * picture files. If such a reference has a relative path, then the
60 * copied .fig file will require a transformation of the picture file
61 * reference if it is to be found by XFig.
63 struct SpecialisedMover : public Mover
67 /** @c command should be of the form
69 * sh $$s/copy_fig.sh $$i $$o
71 * where $$s is a placeholder for the lyx script directory,
72 * $$i is a placeholder for the name of the file to be moved,
73 * $$o is a placeholder for the name of the file after moving.
75 SpecialisedMover(std::string const & command)
76 : command_(command) {}
78 /// The template used to launch the external command.
79 std::string const & command() const { return command_; }
83 do_copy(std::string const & from, std::string const & to) const;
86 do_rename(std::string const & from, std::string const & to) const;
93 * Manage the store of (Mover)s.
98 /** Register a specialised @c command to be used to copy a file
101 void set(std::string const & fmt, std::string const & command);
103 /// @c returns the Mover registered for format @c fmt.
104 Mover const & operator()(std::string const & fmt) const;
106 /** @returns the command template if @c fmt 'finds' a
107 * SpecialisedMover. Otherwise, returns an empty string.
109 std::string const command(std::string const & fmt) const;
112 typedef std::map<std::string, SpecialisedMover> SpecialsMap;
115 typedef SpecialsMap::const_iterator iterator;
116 iterator begin() const { return specials_.begin(); }
117 iterator end() const { return specials_.end(); }
121 SpecialsMap specials_;
125 extern Movers movers;
126 extern Movers system_movers;