diff options
Diffstat (limited to 'src/tools')
| -rwxr-xr-x | src/tools/fileutils.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c index 80a0ec60..06299fc0 100755 --- a/src/tools/fileutils.c +++ b/src/tools/fileutils.c @@ -15,10 +15,10 @@ #include "debug.h" #include "fileutils.h" -static const char* x86sign = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x03" "\x00"; -static const char* x64sign = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x3e" "\x00"; static const char* x86lib = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x03" "\x00"; static const char* x64lib = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x3e" "\x00"; +static const char* bashsign= "#!/bin/bash"; +static const char* shsign = "#!/bin/sh"; int FileExist(const char* filename, int flags) { @@ -99,6 +99,24 @@ int FileIsX86ELF(const char* filename) return 0; } +int FileIsShell(const char* filename) +{ + FILE *f = fopen(filename, "rb"); + if(!f) + return 0; + char head[20] = {0}; + int sz = fread(head, strlen(bashsign), 1, f); + fclose(f); + if(sz!=1) { + return 0; + if(memcmp(head, bashsign, strlen(bashsign))==0) + return 1; + } + if(memcmp(head, shsign, strlen(shsign))==0) + return 1; + return 0; +} + #if defined(RPI) || defined(RK3399) || defined(RK3326) void sanitize_mojosetup_gtk_background() { |