static int _check_dir_path(const char *dir_path, uid_t uid)
{
ms_user_storage_type_e storage_type;
- int ret = MS_MEDIA_ERR_NONE;
-
- ret = ms_user_get_storage_type(uid, dir_path, &storage_type);
- MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INVALID_PATH, "Invalid path");
- if (g_file_test(dir_path, G_FILE_TEST_EXISTS)) {
- if (!g_file_test(dir_path, G_FILE_TEST_IS_DIR))
- MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INVALID_PATH, "Invalid path : %s is not directory", dir_path);
- }
+ MSAPI_RETV_IF(!g_file_test(dir_path, G_FILE_TEST_IS_DIR), MS_MEDIA_ERR_INVALID_PATH);
- return MS_MEDIA_ERR_NONE;
+ return ms_user_get_storage_type(uid, dir_path, &storage_type);
}
/* receive message from media-server[function : ms_receive_message_from_scanner] */
int ret = MS_MEDIA_ERR_NONE;
ret = _check_dir_path(directory_path, uid);
- MSAPI_RETV_IF(ret != MS_MEDIA_ERR_NONE, ret);
+ MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Invalid path");
if (recursive_on)
ret = __media_db_request_update_async(MS_MSG_DIRECTORY_SCANNING, storage_id, directory_path, user_callback, user_data, uid);
int ret = MS_MEDIA_ERR_NONE;
ret = _check_dir_path(directory_path, uid);
- MSAPI_RETV_IF(ret != MS_MEDIA_ERR_NONE, ret);
+ MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Invalid path");
ret = __media_db_request_update_cancel(MS_MSG_DIRECTORY_SCANNING_CANCEL, directory_path);
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
- GArray *thumb_list = NULL;
+ GPtrArray *thumb_list = NULL;
+ char *path = NULL;
+ int i = 0;
MS_DBG_RETVM_IF(!MS_STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
- thumb_list = g_array_new(FALSE, FALSE, sizeof(char*));
+ thumb_list = g_ptr_array_new_with_free_func(g_free);
char *sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM '%q' WHERE validity IN (%d, %d) AND media_thumbnail_path IS NOT NULL", storage_id, MS_INVALID, MS_SCANNING);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Query failed. err[%d]", ret);
while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
- char *path = NULL;
path = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
- g_array_append_val(thumb_list, path);
+ g_ptr_array_add(thumb_list, path);
}
MS_SQLITE3_FINALIZE(sql_stmt);
ret = media_db_update_db_direct(sql, uid);
MS_SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
- while ((thumb_list != NULL) && (thumb_list->len != 0)) {
- char *thumb_path = NULL;
- thumb_path = g_array_index(thumb_list , char*, 0);
- g_array_remove_index(thumb_list, 0);
- MS_SAFE_FREE(thumb_path);
- }
- g_array_free(thumb_list, false);
- thumb_list = NULL;
+ g_ptr_array_free(thumb_list, TRUE);
return ret;
}
/*Delete thumbnails*/
- while ((thumb_list != NULL) && (thumb_list->len != 0)) {
- char *thumb_path = NULL;
- thumb_path = g_array_index(thumb_list , char*, 0);
- g_array_remove_index(thumb_list, 0);
+ for (i = 0; i < thumb_list->len; i++) {
+ path = g_ptr_array_index(thumb_list, i);
- if (remove(thumb_path) != 0)
+ if (remove(path) != 0)
MS_DBG_ERR("fail to remove thumbnail file.");
-
- MS_SAFE_FREE(thumb_path);
}
- g_array_free(thumb_list, false);
- thumb_list = NULL;
+ g_ptr_array_free(thumb_list, TRUE);
return MS_MEDIA_ERR_NONE;
}