improve: TMP_PATH related code

This commit improves the code that decides which path will be for "TMP_PATH" variable.
This commit is contained in:
ThePedroo
2024-06-30 19:25:52 -03:00
parent 5da73dd053
commit 80c873c8a4

View File

@@ -14,18 +14,15 @@ int main(int argc, char **argv) {
if (getenv("TMP_PATH") == NULL) { if (getenv("TMP_PATH") == NULL) {
tmp_path_type = SBIN_AS_TMP_PATH; tmp_path_type = SBIN_AS_TMP_PATH;
FILE *fp = fopen("/sbin", "r"); if (access("/sbin", F_OK) == -1) {
if (fp == NULL) {
tmp_path_type = DEBUG_RAMDISK_AS_TMP_PATH; tmp_path_type = DEBUG_RAMDISK_AS_TMP_PATH;
fp = fopen("/debug_ramdisk", "r"); if (access("/debug_ramdisk", F_OK) == -1) {
if (fp == NULL) {
printf("Cannot find TMP_PATH. You should make an issue about that.\n"); printf("Cannot find TMP_PATH. You should make an issue about that.\n");
return 1; return 1;
} else fclose(fp); }
} else fclose(fp); }
} else { } else {
tmp_path_type = CUSTOM_TMP_PATH; tmp_path_type = CUSTOM_TMP_PATH;
} }