Change return type to bool
[platform/core/api/media-content.git] / src / media_util_private.c
index 9df5125..c8ca777 100755 (executable)
@@ -125,11 +125,10 @@ int _media_util_get_file_time(const char *path)
        return statbuf.st_mtime;
 }
 
-int _media_util_check_ignore_file(const char *path, bool *ignore)
+bool _media_util_is_ignorable_file(const char *path)
 {
        content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
 
-       *ignore = FALSE;
        char *tmp_path = NULL;
        char *org_path = NULL;
 
@@ -140,23 +139,21 @@ int _media_util_check_ignore_file(const char *path, bool *ignore)
        /* Check is exist (It may be the path to the deleted file) */
        if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
                content_sec_debug("removed path[%s]", path);
-               return MEDIA_CONTENT_ERROR_NONE;
+               return false;
        }
 
        /* Check symbolic link file */
        if (g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
-               *ignore = TRUE;
                content_error("symbolic link(file)");
                content_sec_debug("path : %s", path);
-               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               return true;
        }
 
        /* Check hidden path */
        if (strstr(path, "/.") != NULL) {
-               *ignore = TRUE;
                content_error("hidden path");
                content_sec_debug("path : %s", path);
-               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               return true;
        }
 
        /* Check symbolic directory */
@@ -166,40 +163,37 @@ int _media_util_check_ignore_file(const char *path, bool *ignore)
 
 #ifdef _USE_TVPD_MODE
        if (g_strcmp0(tmp_path, org_path) != 0) {
-               *ignore = TRUE;
                content_error("symbolic link(directory)");
                content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
                SAFE_FREE(tmp_path);
                SAFE_FREE(org_path);
-               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               return true;
        }
 #else
        if (g_str_has_prefix(tmp_path, MEDIA_SHARE_PATH)) {
                /* If shared dirctory, it should be change path to TZ_USER_SHARE from realpath */
                snprintf(replace, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), tmp_path + strlen(MEDIA_SHARE_PATH));
                if (g_strcmp0(replace, org_path) != 0) {
-                       *ignore = TRUE;
                        content_error("symbolic link(directory)");
                        content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
                        SAFE_FREE(tmp_path);
                        SAFE_FREE(org_path);
-                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       return true;
                }
        } else {
                if (g_strcmp0(tmp_path, org_path) != 0) {
-                       *ignore = TRUE;
                        content_error("symbolic link(directory)");
                        content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
                        SAFE_FREE(tmp_path);
                        SAFE_FREE(org_path);
-                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       return true;
                }
        }
 #endif
        SAFE_FREE(tmp_path);
        SAFE_FREE(org_path);
 
-       return MEDIA_CONTENT_ERROR_NONE;
+       return false;
 }
 
 static bool __is_scan_ignore_exist(const char *path)
@@ -222,7 +216,7 @@ static bool __is_scan_ignore_exist(const char *path)
        return (bool)result;
 }
 
-int _media_util_check_ignore_dir(const char *dir_path, bool *ignore)
+bool _media_util_is_ignorable_dir(const char *dir_path)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
@@ -230,19 +224,17 @@ int _media_util_check_ignore_dir(const char *dir_path, bool *ignore)
        content_retvm_if(!STRING_VALID(dir_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dir_path");
        content_sec_debug("dir_path : %s", dir_path);
 
-       *ignore = false;
        /*1. Check Hidden Directory*/
        if (strstr(dir_path, "/.") != NULL) {
-               *ignore = true;
                content_error("hidden path");
-               return MEDIA_CONTENT_ERROR_NONE;
+               return true;
        }
 
        /*2. Check Scan Ignore Directory*/
        ret = ms_user_get_storage_type(_content_get_uid(), dir_path, &storage_type);
        if (ret != MS_MEDIA_ERR_NONE) {
                content_error("ms_user_get_storage_type failed : %d", ret);
-               return _content_error_capi(ret);
+               return false;
        }
 
        char *leaf_path = NULL;
@@ -252,8 +244,8 @@ int _media_util_check_ignore_dir(const char *dir_path, bool *ignore)
        SAFE_STRLCPY(search_path, dir_path, sizeof(search_path));
 
        while (STRING_VALID(search_path)) {
-               if ((*ignore = __is_scan_ignore_exist(search_path)))
-                       break;
+               if (__is_scan_ignore_exist(search_path))
+                       return true;
 
                leaf_path = strrchr(search_path, '/');
                if (!leaf_path)
@@ -262,7 +254,7 @@ int _media_util_check_ignore_dir(const char *dir_path, bool *ignore)
                search_path[leaf_path - search_path] = '\0';
        }
 
-       return MEDIA_CONTENT_ERROR_NONE;
+       return false;
 }
 
 int _media_content_check_dir(const char *path)