mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 07:36:00 +01:00
Merge branch 'staging-mime' into develop
Conflicts: Makefile config.mk document.c
This commit is contained in:
commit
c6c0fd1ce2
1 changed files with 13 additions and 11 deletions
24
document.c
24
document.c
|
@ -521,7 +521,7 @@ static const gchar*
|
||||||
guess_type(const char* path)
|
guess_type(const char* path)
|
||||||
{
|
{
|
||||||
#ifdef WITH_MAGIC
|
#ifdef WITH_MAGIC
|
||||||
const gchar *content_type = NULL;
|
const char* mime_type = NULL;
|
||||||
const int flags =
|
const int flags =
|
||||||
MAGIC_MIME_TYPE |
|
MAGIC_MIME_TYPE |
|
||||||
MAGIC_SYMLINK |
|
MAGIC_SYMLINK |
|
||||||
|
@ -532,22 +532,25 @@ guess_type(const char* path)
|
||||||
magic_t magic = magic_open(flags);
|
magic_t magic = magic_open(flags);
|
||||||
if (magic == NULL) {
|
if (magic == NULL) {
|
||||||
girara_debug("failed creating the magic cookie\n");
|
girara_debug("failed creating the magic cookie\n");
|
||||||
return NULL;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (magic_load(magic, NULL) < 0) {
|
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;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
const char* mime_type = magic_file(magic, path);
|
mime_type = magic_file(magic, path);
|
||||||
if (mime_type == NULL) {
|
if (mime_type == NULL) {
|
||||||
girara_warning("failed guessing filetype: %s\n", magic_error(magic));
|
girara_debug("failed guessing filetype: %s\n", magic_error(magic));
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
content_type = g_strdup(mime_type);
|
|
||||||
cleanup:
|
cleanup:
|
||||||
magic_close(magic);
|
if (magic != NULL) {
|
||||||
return content_type;
|
magic_close(magic);
|
||||||
#else
|
}
|
||||||
|
if (mime_type != NULL) {
|
||||||
|
return g_strdup(mime_type);
|
||||||
|
}
|
||||||
|
/* else fallback to g_content_type_guess method */
|
||||||
|
#endif /*WITH_MAGIC*/
|
||||||
gboolean uncertain = FALSE;
|
gboolean uncertain = FALSE;
|
||||||
const gchar* content_type = g_content_type_guess(path, NULL, 0, &uncertain);
|
const gchar* content_type = g_content_type_guess(path, NULL, 0, &uncertain);
|
||||||
if (content_type == NULL) {
|
if (content_type == NULL) {
|
||||||
|
@ -620,7 +623,6 @@ cleanup:
|
||||||
|
|
||||||
g_strdelimit(out, "\n\r", '\0');
|
g_strdelimit(out, "\n\r", '\0');
|
||||||
return out;
|
return out;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_plugin_t*
|
zathura_plugin_t*
|
||||||
|
|
Loading…
Reference in a new issue