Simplify get_temp_directory_alloc

This commit is contained in:
twinaphex 2020-01-30 20:05:44 +01:00
parent e31ba43b5a
commit d7c2eba4fd

View File

@ -10832,13 +10832,13 @@ static void clear_controller_port_map(void)
static char *get_temp_directory_alloc(void) static char *get_temp_directory_alloc(void)
{ {
const char *src;
char *path = NULL; char *path = NULL;
#ifdef _WIN32 #ifdef _WIN32
#ifdef LEGACY_WIN32 #ifdef LEGACY_WIN32
DWORD path_length = GetTempPath(0, NULL) + 1; DWORD path_length = GetTempPath(0, NULL) + 1;
path = (char*)malloc(path_length * sizeof(char));
if (!path) if (!(path = (char*)malloc(path_length * sizeof(char))))
return NULL; return NULL;
path[path_length - 1] = 0; path[path_length - 1] = 0;
@ -10856,17 +10856,16 @@ static char *get_temp_directory_alloc(void)
path = utf16_to_utf8_string_alloc(wide_str); path = utf16_to_utf8_string_alloc(wide_str);
free(wide_str); free(wide_str);
#endif #endif
#elif defined ANDROID #else
{ #if defined ANDROID
settings_t *settings = configuration_settings; src = configuration_settings->paths.directory_libretro;
path = strcpy_alloc_force(settings->paths.directory_libretro);
}
#else #else
if (getenv("TMPDIR")) if (getenv("TMPDIR"))
path = strcpy_alloc_force(getenv("TMPDIR")); src = getenv("TMPDIR");
else else
path = strcpy_alloc_force("/tmp"); src = "/tmp";
#endif
path = strcpy_alloc_force(src);
#endif #endif
return path; return path;
} }