From 0ff09e81b187451b37ca24f19164e2046f5d4117 Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Thu, 18 May 2017 15:56:19 +0900 Subject: [PATCH] Add API of getting thumbnail store path Change-Id: Ic080a797a46111b76fb6553e07a91325d8e2576a --- lib/include/media-util-user.h | 3 ++ lib/media-util-user.c | 65 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/lib/include/media-util-user.h b/lib/include/media-util-user.h index 1335ce9..723314e 100755 --- a/lib/include/media-util-user.h +++ b/lib/include/media-util-user.h @@ -32,6 +32,9 @@ typedef enum { int ms_user_get_internal_root_path(uid_t uid, char **path); int ms_user_get_storage_type(uid_t uid, const char *path, ms_user_storage_type_t *storage_type); +int ms_user_get_root_thumb_store_path(uid_t uid, char **path); +int ms_user_get_default_thumb_store_path(uid_t uid, char **path); +int ms_user_get_mmc_thumb_store_path(uid_t uid, char **path); #ifdef __cplusplus } diff --git a/lib/media-util-user.c b/lib/media-util-user.c index 663b05a..9bd06bb 100755 --- a/lib/media-util-user.c +++ b/lib/media-util-user.c @@ -77,3 +77,68 @@ int ms_user_get_storage_type(uid_t uid, const char *path, ms_user_storage_type_t return ret; } + +int ms_user_get_root_thumb_store_path(uid_t uid, char **path) +{ + int ret = MS_MEDIA_ERR_NONE; + + if (uid == getuid()) { + const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb"); + *path = g_strndup(result, strlen(result)); + } else { + ret = tzplatform_set_user(uid); + MSAPI_RETVM_IF(ret != 0, MS_MEDIA_ERR_INTERNAL, "Invalid UID[%d]", uid); + + const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb"); + *path = g_strndup(result, strlen(result)); + + tzplatform_reset_user(); + } + + //MSAPI_DBG_SLOG("thumb path [%s]", *path); + + return ret; +} +int ms_user_get_default_thumb_store_path(uid_t uid, char **path) +{ + int ret = MS_MEDIA_ERR_NONE; + + if (uid == getuid()) { + const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone"); + *path = g_strndup(result, strlen(result)); + } else { + ret = tzplatform_set_user(uid); + MSAPI_RETVM_IF(ret != 0, MS_MEDIA_ERR_INTERNAL, "Invalid UID[%d]", uid); + + const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone"); + *path = g_strndup(result, strlen(result)); + + tzplatform_reset_user(); + } + + //MSAPI_DBG_SLOG("thumb path [%s]", *path); + + return ret; +} + +int ms_user_get_mmc_thumb_store_path(uid_t uid, char **path) +{ + int ret = MS_MEDIA_ERR_NONE; + + if (uid == getuid()) { + const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc"); + *path = g_strndup(result, strlen(result)); + } else { + ret = tzplatform_set_user(uid); + MSAPI_RETVM_IF(ret != 0, MS_MEDIA_ERR_INTERNAL, "Invalid UID[%d]", uid); + + const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc"); + *path = g_strndup(result, strlen(result)); + + tzplatform_reset_user(); + } + + //MSAPI_DBG_SLOG("thumb path [%s]", *path); + + return ret; +} -- 2.7.4