Commit c6c0fd1c authored by Sebastian Ramacher's avatar Sebastian Ramacher
Browse files

Merge branch 'staging-mime' into develop

Conflicts:
	Makefile
	config.mk
	document.c
parents 4b1edf1a 1d23f466
......@@ -521,7 +521,7 @@ static const gchar*
guess_type(const char* path)
{
#ifdef WITH_MAGIC
const gchar *content_type = NULL;
const char* mime_type = NULL;
const int flags =
MAGIC_MIME_TYPE |
MAGIC_SYMLINK |
......@@ -532,22 +532,25 @@ guess_type(const char* path)
magic_t magic = magic_open(flags);
if (magic == NULL) {
girara_debug("failed creating the magic cookie\n");
return NULL;
goto cleanup;
}
if (magic_load(magic, NULL) < 0) {
girara_warning("failed loading the magic database: %s\n", magic_error(magic));
girara_debug("failed loading the magic database: %s\n", magic_error(magic));
goto cleanup;
}
const char* mime_type = magic_file(magic, path);
mime_type = magic_file(magic, path);
if (mime_type == NULL) {
girara_warning("failed guessing filetype: %s\n", magic_error(magic));
goto cleanup;
girara_debug("failed guessing filetype: %s\n", magic_error(magic));
}
content_type = g_strdup(mime_type);
cleanup:
magic_close(magic);
return content_type;
#else
if (magic != NULL) {
magic_close(magic);
}
if (mime_type != NULL) {
return g_strdup(mime_type);
}
/* else fallback to g_content_type_guess method */
#endif /*WITH_MAGIC*/
gboolean uncertain = FALSE;
const gchar* content_type = g_content_type_guess(path, NULL, 0, &uncertain);
if (content_type == NULL) {
......@@ -620,7 +623,6 @@ cleanup:
g_strdelimit(out, "\n\r", '\0');
return out;
#endif
}
zathura_plugin_t*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment