From: Minje Ahn Date: Mon, 3 May 2021 00:38:06 +0000 (+0900) Subject: Reinforce readability X-Git-Tag: accepted/tizen/unified/20210505.141434~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a09b11b3ae391e9a194294f1e328dc4f7ba50379;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Reinforce readability Change-Id: Ib75f40bb414d4c29314eee2e2c832aafcd0043d2 Signed-off-by: Minje Ahn --- diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 2e71b30..f0c10ad 100644 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -531,41 +531,20 @@ static char *__media_svc_get_title_from_filepath(const char *path) { char *filename = NULL; char *title = NULL; - char *ext = NULL; - int filename_len = -1; - int new_title_len = -1; + char *last_dot = NULL; - if (!path) { - media_svc_error("path is NULL"); - return NULL; - } + media_svc_retvm_if(!STRING_VALID(path), NULL, "Invalid path"); filename = g_path_get_basename(path); - if (!STRING_VALID(filename)) { - media_svc_error("wrong file name"); - g_free(filename); - return NULL; - } - filename_len = strlen(filename); - - ext = g_strrstr(filename, "."); - if (!ext) { - media_svc_error("there is no file extention"); - return filename; - } - - new_title_len = filename_len - strlen(ext); - if (new_title_len < 1) { - media_svc_error("title length is zero"); + last_dot = strrchr(filename, '.'); + if (last_dot) { + title = g_strndup(filename, last_dot - filename); g_free(filename); - return NULL; + } else { + title = filename; } - title = g_strndup(filename, new_title_len < MEDIA_SVC_PATHNAME_SIZE ? new_title_len : MEDIA_SVC_PATHNAME_SIZE - 1); - - g_free(filename); - media_svc_debug("extract title is [%s]", title); return title;