static int __get_sdcard_path(char **sdpath)
{
- int ret;
+ static int ret = STORAGE_ERROR_NONE;
+ static char sdcard_path[MAX_PATH_LENGTH];
int storage_id;
+ char *tmp_path;
if (sdpath == NULL)
return -1;
- ret = storage_get_primary_sdcard(&storage_id, sdpath);
- if (ret != STORAGE_ERROR_NONE)
+ if (ret == STORAGE_ERROR_NOT_SUPPORTED)
return -1;
+ if (sdcard_path[0] == '\0') {
+ ret = storage_get_primary_sdcard(&storage_id, &tmp_path);
+ if (ret != STORAGE_ERROR_NONE || tmp_path == NULL)
+ return -1;
+ snprintf(sdcard_path, MAX_PATH_LENGTH, "%s", tmp_path);
+ free(tmp_path);
+ }
+
+ *sdpath = strdup(sdcard_path);
return 0;
}