24 #include <core/exception.h> 25 #include <utils/system/filetype.h> 31 #include <sys/types.h> 50 magic_t m = magic_open(MAGIC_ERROR);
53 const char *res = magic_file(m, filename);
55 fawkes::Exception e(
"Failed to determine file type of %s: %s", filename, magic_error(m));
64 "(libmagic not available at compile time)",
85 magic_t m = magic_open(MAGIC_ERROR);
88 const char *res = magic_descriptor(m, fd);
90 fawkes::Exception e(
"Failed to determine file type of descriptor: %s", magic_error(m));
99 "(libmagic not available at compile time)");
116 # ifdef MAGIC_MIME_TYPE 117 magic_t m = magic_open(MAGIC_ERROR | MAGIC_MIME_TYPE);
119 magic_t m = magic_open(MAGIC_ERROR | MAGIC_MIME);
123 const char *res = magic_file(m, filename);
125 fawkes::Exception e(
"Failed to determine mime type of %s: %s", filename, magic_error(m));
131 # ifndef MAGIC_MIME_TYPE 132 rv = rv.substr(0, rv.find(
","));
137 "(libmagic not available at compile time)",
156 # ifdef MAGIC_MIME_TYPE 157 magic_t m = magic_open(MAGIC_ERROR | MAGIC_MIME_TYPE);
159 magic_t m = magic_open(MAGIC_ERROR | MAGIC_MIME);
163 const char *res = magic_descriptor(m, fd);
165 fawkes::Exception e(
"Failed to determine mime type of descriptor: %s", magic_error(m));
171 # ifndef MAGIC_MIME_TYPE 172 rv = rv.substr(0, rv.find(
","));
177 "(libmagic not available at compile time)");
Fawkes library namespace.
std::string mimetype_file(const char *filename)
Get mime-type of file.
Base class for exceptions in Fawkes.
std::string filetype_file(const char *filename)
Get filetype of file.