diff options
Diffstat (limited to 'src/tools/fileutils.c')
| -rwxr-xr-x | src/tools/fileutils.c | 22 |
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() { |