From dcb4bbb3e622f657f94e5ce3e79a1557281643cc Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 18 Sep 2022 19:00:53 +0200 Subject: More fixes and improvment to bash handling (helps #360) --- src/tools/fileutils.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/tools') diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c index 06299fc0..42524ee8 100755 --- a/src/tools/fileutils.c +++ b/src/tools/fileutils.c @@ -107,16 +107,30 @@ int FileIsShell(const char* filename) char head[20] = {0}; int sz = fread(head, strlen(bashsign), 1, f); fclose(f); - if(sz!=1) { + if(sz!=1) return 0; - if(memcmp(head, bashsign, strlen(bashsign))==0) + head[strlen(bashsign)+1] = 0; + if(!strcmp(head, bashsign)) return 1; - } - if(memcmp(head, shsign, strlen(shsign))==0) + head[strlen(shsign)+1] = 0; + if(!strcmp(head, shsign)) return 1; return 0; } +const char* GetTmpDir() { + char *tmpdir; + if ((tmpdir = getenv ("TMPDIR")) != NULL) return tmpdir; + if ((tmpdir = getenv ("TEMP")) != NULL) return tmpdir; + if ((tmpdir = getenv ("TMP")) != NULL) return tmpdir; + if(FileExist("/tmp", 0)) return "/tmp"; + if(FileExist("/var/tmp", 0)) return "/var/tmp"; + if(FileExist("/usr/tmp", 0)) return "/usr/tmp"; + + return "/tmp"; // meh... +} + + #if defined(RPI) || defined(RK3399) || defined(RK3326) void sanitize_mojosetup_gtk_background() { -- cgit 1.4.1