diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-30 16:01:31 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-30 16:01:31 -0500 |
commit | 96145d5fdc0d695414f200c2afa372818f4857df (patch) | |
tree | 84747df601a2f3688cefe15eaf9fbfe411e891c8 /src/mime.c | |
parent | d0e254663e64e40b676644038a9d7c95a2f25116 (diff) | |
download | spmc-96145d5fdc0d695414f200c2afa372818f4857df.tar.gz |
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
Diffstat (limited to 'src/mime.c')
-rw-r--r-- | src/mime.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -2,6 +2,7 @@ * @file mime.c */ #include "spm.h" +#include <fnmatch.h> /** * 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 |