4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Jean-Marc Lasgouttes
9 * Full author contact details are available in file CREDITS.
15 #include "support/debug.h"
25 Magic() : ok_(false) {
26 cookie_ = magic_open(MAGIC_MIME);
28 if (magic_load(cookie_, NULL) != 0)
29 LYXERR(Debug::GRAPHICS, "Magic: couldn't load magic database - "
30 << magic_error(cookie_));
41 // returns a string of the form "mime-type;encoding", or an empty string on error.
42 std::string file(std::string const & name) const {
46 char const * result = magic_file(cookie_, name.c_str());
50 LYXERR(Debug::GRAPHICS, "Magic: couldn't query magic database - "
51 << magic_error(cookie_));
61 #else // !HAVE_MAGIC_T
63 // A dummy Magic class that always returns an empty result
67 LYXERR(Debug::GRAPHICS, "Magic: libmagic support not configured");
70 std::string file(std::string const & ) const { return empty_string(); }
73 #endif // HAVE_MAGIC_T