From 96145d5fdc0d695414f200c2afa372818f4857df Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 30 Dec 2019 16:01:31 -0500 Subject: Fixes * Verbosity++ * If no requirements are present do not to report we are installing some * Redirect all shell output to stderr (need a better way) * implemented file_is_binexec() to avoid running patchelf on generic data files --- src/mime.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/mime.c') diff --git a/src/mime.c b/src/mime.c index 9fcf97b..53501cc 100644 --- a/src/mime.c +++ b/src/mime.c @@ -2,6 +2,7 @@ * @file mime.c */ #include "spm.h" +#include /** * Execute OS `file` command @@ -16,7 +17,7 @@ Process *file_command(const char *_filename) { #ifdef __APPLE__ const char *fmt_cmd = "file -I \"%s\""; #else // GNU - const char *fmt_cmd = "file -E -i \"%s\""; + const char *fmt_cmd = "file -E -i \"%s\" 2>&1"; #endif strchrdel(filename, "&;|"); @@ -121,4 +122,16 @@ int file_is_binary(const char *filename) { free(path); mime_free(type); return result; +} + +int file_is_binexec(const char *filename) { + int result = 0; + char *path = normpath(filename); + Mime *type = file_mimetype(path); + if (fnmatch("application/*executable", type->type, FNM_PATHNAME) != FNM_NOMATCH && strcmp(type->charset, "binary") == 0) { + result = 1; + } + free(path); + mime_free(type); + return result; } \ No newline at end of file -- cgit