about summary refs log tree commit diff stats
path: root/src/tools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-09-18 19:00:53 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-09-18 19:00:53 +0200
commitdcb4bbb3e622f657f94e5ce3e79a1557281643cc (patch)
tree0c6af4c289d9ac04bb4219b1a102afc615853e5b /src/tools
parent21c56e78988e424ef027985312b4e376a84c15f9 (diff)
downloadbox64-dcb4bbb3e622f657f94e5ce3e79a1557281643cc.tar.gz
box64-dcb4bbb3e622f657f94e5ce3e79a1557281643cc.zip
More fixes and improvment to bash handling (helps #360)
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/fileutils.c22
1 files changed, 18 insertions, 4 deletions
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()
 {