int _media_util_check_file_exist(const char *path);
void _media_util_trim_path(const char *input_path, char **output_path);
int _media_util_get_file_time(const char *path);
-int _media_util_check_ignore_file(const char *path, bool *ignore);
-int _media_util_check_ignore_dir(const char *dir_path, bool *ignore);
+bool _media_util_is_ignorable_file(const char *path);
+bool _media_util_is_ignorable_dir(const char *dir_path);
int _media_content_check_dir(const char *path);
char * _media_content_replace_path_in_condition(const char *condition);
int _media_content_replace_path(const char *path, char *replace_path);
int _media_util_check_file_exist(const char *path);
void _media_util_trim_path(const char *input_path, char **output_path);
int _media_util_get_file_time(const char *path);
-int _media_util_check_ignore_file(const char *path, bool *ignore);
-int _media_util_check_ignore_dir(const char *dir_path, bool *ignore);
+bool _media_util_is_ignorable_file(const char *path);
+bool _media_util_is_ignorable_dir(const char *dir_path);
int _media_content_check_dir(const char *path);
char * _media_content_replace_path_in_condition(const char *condition);
int _media_content_replace_path(const char *path, char *replace_path);
int media_content_scan_file(const char *path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- bool ignore_file = FALSE;
- bool ignore_dir = FALSE;
char *folder_path = NULL;
int check_file = MEDIA_CONTENT_ERROR_NONE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
ret = _media_content_replace_path(path, repl_path);
content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = _media_util_check_ignore_file(repl_path, &ignore_file);
- content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+ content_retvm_if(_media_util_is_ignorable_file(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
memset(storage_id, 0x00, sizeof(storage_id));
ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (check_file == MEDIA_CONTENT_ERROR_NONE) {
/* This means this path has to be inserted or refreshed */
folder_path = g_path_get_dirname(repl_path);
- ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
- g_free(folder_path);
- content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+ if (_media_util_is_ignorable_dir(folder_path)) {
+ g_free(folder_path);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
/* check feature */
content_retvm_if(!_media_util_check_support_media_type(repl_path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
int media_content_scan_folder(const char *path, bool is_recursive, media_scan_completed_cb callback, void *user_data)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- bool ignore_dir = FALSE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
char repl_path[MAX_PATH_LEN] = {0, };
ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
if (ret == MEDIA_CONTENT_ERROR_NONE) {
/* If directory exist check that's ignore directory or not*/
- ret = _media_util_check_ignore_dir(repl_path, &ignore_dir);
- content_retvm_if((ignore_dir == TRUE || ret != MEDIA_CONTENT_ERROR_NONE), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+ content_retvm_if(_media_util_is_ignorable_dir(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
} else {
/* This means this folder has to be deleted */
/* Or, it is real invalid path.. check storage type */
int media_content_scan_folder_v2(const char *path, bool is_recursive, media_scan_completed_cb_v2 callback, void *user_data)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- bool ignore_dir = FALSE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
memset(storage_id, 0x00, sizeof(storage_id));
- ret = _media_util_check_ignore_dir(path, &ignore_dir);
- content_retvm_if(ignore_dir, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+ content_retvm_if(_media_util_is_ignorable_dir(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
ret = _media_content_check_dir(path);
content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied");
char repl_path[MAX_PATH_LEN] = {0, };
int ret = MEDIA_CONTENT_ERROR_NONE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- bool ignore_dir = FALSE;
content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
memset(repl_path, 0, sizeof(repl_path));
ret = _media_content_replace_path(path, repl_path);
content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = _media_util_check_ignore_dir(repl_path, &ignore_dir);
- content_retvm_if(ignore_dir, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+ content_retvm_if(_media_util_is_ignorable_dir(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
ret = _media_content_check_dir(repl_path);
content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied");
static int __media_info_check_file_validity(const char *path)
{
- bool ignore = FALSE;
char *folder_path = NULL;
int ret = MEDIA_CONTENT_ERROR_NONE;
content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
- ret = _media_util_check_ignore_file(path, &ignore);
- content_retvm_if(ignore == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid ignore path");
+ content_retvm_if(_media_util_is_ignorable_file(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid ignore path");
ret = _media_util_check_file_exist(path);
content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "invalid path");
folder_path = g_path_get_dirname(path);
- ret = _media_util_check_ignore_dir(folder_path, &ignore);
+ if (_media_util_is_ignorable_dir(folder_path))
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+
g_free(folder_path);
- content_retvm_if(ignore == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
- return MEDIA_CONTENT_ERROR_NONE;
+ return ret;
}
void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
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;
/* 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 */
#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)
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;
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;
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)
search_path[leaf_path - search_path] = '\0';
}
- return MEDIA_CONTENT_ERROR_NONE;
+ return false;
}
int _media_content_check_dir(const char *path)