24 #include <utils/system/filetype.h> 25 #include <core/exception.h> 32 #include <sys/types.h> 49 magic_t m = magic_open( MAGIC_ERROR );
50 magic_load( m, NULL );
52 const char * res = magic_file( m, filename );
54 fawkes::Exception e(
"Failed to determine file type of %s: %s", filename, magic_error(m));
63 "(libmagic not available at compile time)",
85 magic_t m = magic_open( MAGIC_ERROR );
86 magic_load( m, NULL );
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)");
117 # ifdef MAGIC_MIME_TYPE 118 magic_t m = magic_open( MAGIC_ERROR | MAGIC_MIME_TYPE );
120 magic_t m = magic_open( MAGIC_ERROR | MAGIC_MIME );
122 magic_load( m, NULL );
124 const char * res = magic_file( m, filename );
126 fawkes::Exception e(
"Failed to determine mime type of %s: %s", filename, magic_error(m));
132 # ifndef MAGIC_MIME_TYPE 133 rv = rv.substr(0, rv.find(
","));
138 "(libmagic not available at compile time)",
158 # ifdef MAGIC_MIME_TYPE 159 magic_t m = magic_open( MAGIC_ERROR | MAGIC_MIME_TYPE );
161 magic_t m = magic_open( MAGIC_ERROR | MAGIC_MIME );
163 magic_load( m, NULL );
165 const char * res = magic_descriptor( m, fd );
167 fawkes::Exception e(
"Failed to determine mime type of descriptor: %s", magic_error(m));
173 # ifndef MAGIC_MIME_TYPE 174 rv = rv.substr(0, rv.find(
","));
179 "(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.