2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include "mf-ug-fs-util.h"
23 #include "mf-ug-util.h"
25 static int __mf_ug_fs_oper_sort_by_date_cb_O2R(const void *d1, const void *d2);
26 static int __mf_ug_fs_oper_sort_by_name_cb_A2Z(const void *d1, const void *d2);
27 static int __mf_ug_fs_oper_sort_by_type_cb_A2Z(const void *d1, const void *d2);
28 static int __mf_ug_fs_oper_sort_by_size_cb_S2L(const void *d1, const void *d2);
29 static int __mf_ug_fs_oper_sort_by_name_cb_Z2A(const void *d1, const void *d2);
30 static int __mf_ug_fs_oper_sort_by_date_cb_R2O(const void *d1, const void *d2);
31 static int __mf_ug_fs_oper_sort_by_type_cb_Z2A(const void *d1, const void *d2);
32 static int __mf_ug_fs_oper_sort_by_size_cb_L2S(const void *d1, const void *d2);
34 /*********************
35 **Function name: __mf_ug_fs_oper_file_system_error
37 ** const char* src: source path
38 ** const char* dst: destination path
39 ** int check_option: check option
45 ** input parameter checking
47 *********************/
48 static const char *__mf_ug_fs_oper_get_file(const char *path)
55 if ((result = strrchr(path, '/'))) {
58 result = (char *)path;
64 static int __mf_ug_fs_oper_file_system_error(const char *src, const char *dst, int check_option)
66 if ((check_option & MF_ERROR_CHECK_SRC_ARG_VALID) && (src == NULL)) {
67 return MYFILE_ERR_SRC_ARG_INVALID;
69 if ((check_option & MF_ERROR_CHECK_SRC_EXIST) && (!ecore_file_exists(src))) {
70 return MYFILE_ERR_SRC_NOT_EXIST;
73 if (check_option & MF_ERROR_CHECK_SRC_PATH_VALID) {
74 if (!ecore_file_is_dir(src)) {
75 if (mf_ug_file_attr_is_right_file_path(src)) {
76 return MYFILE_ERR_INVALID_FILE_PATH;
79 if (mf_ug_file_attr_is_right_dir_path(src)) {
80 return MYFILE_ERR_INVALID_DIR_PATH;
85 if (check_option & MF_ERROR_CHECK_DUPLICATED) {
86 char *parent_path = NULL;
88 if (!mf_ug_file_attr_get_parent_path(dst, &parent_path)) {
89 if (mf_ug_file_attr_is_duplicated_name(parent_path, __mf_ug_fs_oper_get_file(dst))) {
90 UG_SAFE_FREE_CHAR(parent_path);
91 return MYFILE_ERR_DUPLICATED_NAME;
93 UG_SAFE_FREE_CHAR(parent_path);
95 UG_SAFE_FREE_CHAR(parent_path);
96 return MYFILE_ERR_GET_PARENT_PATH_FAIL;
99 return MYFILE_ERR_NONE;
102 /*********************
103 **Function name: mf_ug_fs_oper_read_dir
105 ** char *path: path which we need to read
106 ** Eina_List** dir_list: output parameter of dir list under specified path
107 ** Eina_List** file_list: output parameter of file list under specified path
113 ** read element under the specified path
115 *********************/
116 int mf_ug_fs_oper_read_dir(const char *path, Eina_List **dir_list, Eina_List **file_list)
122 ug_mf_retvm_if(path == NULL, MYFILE_ERR_INVALID_ARG, "path is null");
123 ug_mf_retvm_if(dir_list == NULL, MYFILE_ERR_INVALID_ARG, "dir_list is null");
124 ug_mf_retvm_if(file_list == NULL, MYFILE_ERR_INVALID_ARG, "file_list is null");
126 int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_SRC_EXIST | MF_ERROR_CHECK_SRC_PATH_VALID;
127 int ret = __mf_ug_fs_oper_file_system_error(path, NULL, option);
129 if (ret != MYFILE_ERR_NONE) {
133 pDir = opendir(path);
136 return MYFILE_ERR_DIR_OPEN_FAIL;
139 while ((ent = readdir(pDir)) != NULL) {
140 GString *childpath = NULL;
141 ugFsNodeInfo *pNode = NULL;
143 if (strncmp(ent->d_name, ".", 1) == 0 || strcmp(ent->d_name, "..") == 0) {
147 if ((ent->d_type & DT_DIR) == 0 && (ent->d_type & DT_REG) == 0) {
150 #ifdef UG_DEBUG_FOLDER_OPTION
151 if ((ent->d_type & DT_DIR) != 0) {
152 if ((strlen(path) == strlen(PHONE_FOLDER)) && (strcmp(path, PHONE_FOLDER) == 0)
153 && (strlen(ent->d_name) == strlen(DEBUG_FOLDER)) && (strcmp(ent->d_name, DEBUG_FOLDER) == 0)) {
158 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
163 memset(pNode, 0, sizeof(ugFsNodeInfo));
164 snprintf(pNode->path, sizeof(pNode->path), "%s", path);
165 snprintf(pNode->name, sizeof(pNode->name), "%s", ent->d_name);
166 if (ent->d_type & DT_DIR) {
167 pNode->type = UG_FILE_TYPE_DIR;
168 } else if (ent->d_type & DT_REG) {
169 mf_ug_file_attr_get_file_category(ent->d_name, &(pNode->type));
171 childpath = g_string_new(path);
172 if (childpath == NULL) {
177 g_string_append_printf(childpath, "/%s", ent->d_name);
178 mf_ug_file_attr_get_file_stat(childpath->str, &pNode);
179 if (pNode->type == UG_FILE_TYPE_DIR) {
180 ug_mf_debug("dir append\n");
181 *dir_list = eina_list_append(*dir_list, pNode);
183 ug_mf_debug("file append\n");
184 ret = mf_ug_file_attr_get_file_ext(childpath->str, &pNode->ext);
185 if (ret != MYFILE_ERR_NONE) {
188 *file_list = eina_list_append(*file_list, pNode);
191 g_string_free(childpath, TRUE);
196 return MYFILE_ERR_NONE;
199 /*********************
200 **Function name: __mf_ug_fs_oper_exec_filter
202 ** ugFsNodeInfo* pnode_info: the node we need to check for filter
203 ** int option: filter
209 ** check if the node satisfied the filter option
210 *********************/
211 static mf_ug_drm_file_mime_type __mf_ug_fs_oper_get_drm_file_type_by_mime(char *mime_type)
213 gchar **result = NULL;
214 if (mime_type != NULL) {
215 result = g_strsplit(mime_type, "/", 0);
216 if (result && (*result)) {
217 ug_mf_debug("*result is [%s]", *result);
218 if (g_strcmp0(*result, "audio") == 0) {
220 return MF_UG_DRM_RINGTONE_FILE;
221 } else if (g_strcmp0(*result, "image") == 0) {
223 return MF_UG_DRM_IMAGE_FILE;
226 return MF_UG_DRM_UNKNOW_FILE;
230 return MF_UG_DRM_UNKNOW_FILE;
233 return MF_UG_DRM_UNKNOW_FILE;
237 mf_ug_drm_file_mime_type mf_ug_fs_oper_get_drm_type(char *path)
239 drm_result_e res = 0;
240 drm_content_info_s dcf_content_info;
242 res = drm_get_content_info(path, &dcf_content_info);
245 if (res == DRM_RETURN_SUCCESS) {
246 mf_ug_drm_file_mime_type drm_mime_type = __mf_ug_fs_oper_get_drm_file_type_by_mime(dcf_content_info.mime_type);
247 return drm_mime_type;
249 return MF_UG_DRM_UNKNOW_FILE;
253 int mf_ug_fs_oper_drm_is_action_allowed(const char *path, drm_action_type_e action, drm_setas_category_e category)
255 drm_bool_type_e is_allowed = 0;
256 drm_action_allowed_data_s action_data;
259 memset(&action_data,0x0,sizeof(drm_action_allowed_data_s));
260 UG_SAFE_STRCPY(action_data.file_path, path);
262 action_data.data = category;
264 ret = drm_is_action_allowed(action,&action_data,&is_allowed);
265 if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_allowed){
272 bool mf_ug_fs_oper_drm_is_valid(const char *path, drm_permission_type_e perm_type)
274 int res = DRM_RETURN_SUCCESS;
275 drm_license_status_e licence_status = DRM_LICENSE_STATUS_UNDEFINED;
277 res = drm_get_license_status(path, perm_type, &licence_status);
280 ug_error("res is [%d] licence is [%d]", res, licence_status);
281 if (res == DRM_RETURN_SUCCESS && licence_status == DRM_LICENSE_STATUS_VALID) {
288 static bool __mf_ug_fs_oper_exec_drm_filter(ugFsNodeInfo *pnode_info, int option)
290 if (pnode_info == NULL) {
295 char *fullpath = NULL;
296 drm_result_e res = DRM_RETURN_INTERNAL_ERROR;
297 if (option & MF_UG_FILTER_DRM_ALL) {
301 if (option & MF_UG_FILTER_DRM_WITHOUT_FL) {
302 fullpath = g_strconcat(pnode_info->path, "/", pnode_info->name, NULL);
303 res = mf_ug_fs_oper_drm_is_action_allowed(fullpath, DRM_IS_FORWARDING_ALLOWED, DRM_SETAS_NONE);
304 if (res == DRM_RETURN_SUCCESS) {
311 if (option & MF_UG_FILTER_DRM_IMAGE) {
312 fullpath = g_strconcat(pnode_info->path, "/", pnode_info->name, NULL);
314 result = mf_ug_fs_oper_drm_is_action_allowed(fullpath, DRM_HAS_VALID_SETAS_STATUS, DRM_SETAS_WALLPAPER);
316 mf_ug_drm_file_mime_type drm_mime_type = mf_ug_fs_oper_get_drm_type(fullpath);
317 if (drm_mime_type == MF_UG_DRM_IMAGE_FILE)
326 if (option & MF_UG_FILTER_DRM_RINGTONE) {
327 fullpath = g_strconcat(pnode_info->path, "/", pnode_info->name, NULL);
329 result = mf_ug_fs_oper_drm_is_action_allowed(fullpath, DRM_HAS_VALID_SETAS_STATUS, DRM_SETAS_RINGTONE);
331 mf_ug_drm_file_mime_type drm_mime_type = mf_ug_fs_oper_get_drm_type(fullpath);
332 if (drm_mime_type == MF_UG_DRM_RINGTONE_FILE)
345 static bool __mf_ug_fs_oper_exec_filter(ugFsNodeInfo *pnode_info, int option)
347 if (pnode_info == NULL) {
350 if (option & UG_FILTER_CATEGORY_IMAGE) {
351 if (pnode_info->type == UG_FILE_TYPE_IMAGE) {
355 if (option & UG_FILTER_CATEGORY_VIDEO) {
356 if (pnode_info->type == UG_FILE_TYPE_VIDEO) {
360 if (option & UG_FILTER_CATEGORY_SOUND) {
361 if (pnode_info->type == UG_FILE_TYPE_SOUND) {
365 if (option & UG_FILTER_CATEGORY_VOICE) {
366 if (pnode_info->type == UG_FILE_TYPE_VOICE) {
370 if (option & UG_FILTER_CATEGORY_MUSIC) {
371 if (pnode_info->type == UG_FILE_TYPE_MUSIC) {
375 if (option & UG_FILTER_CATEGORY_HTML) {
376 if (pnode_info->type == UG_FILE_TYPE_HTML) {
380 if (option & UG_FILTER_CATEGORY_FLASH) {
381 if (pnode_info->type == UG_FILE_TYPE_FLASH) {
385 if (option & UG_FILTER_CATEGORY_GAME) {
386 if (pnode_info->type == UG_FILE_TYPE_GAME) {
390 if (option & UG_FILTER_CATEGORY_APP) {
391 if (pnode_info->type == UG_FILE_TYPE_APP) {
395 if (option & UG_FILTER_CATEGORY_THEME) {
396 if (pnode_info->type == UG_FILE_TYPE_THEME) {
400 if (option & UG_FILTER_CATEGORY_DOC) {
401 if (pnode_info->type == UG_FILE_TYPE_DOC) {
405 if (option & UG_FILTER_CATEGORY_EXCEL) {
406 if (pnode_info->type == UG_FILE_TYPE_EXCEL) {
410 if (option & UG_FILTER_CATEGORY_PPT) {
411 if (pnode_info->type == UG_FILE_TYPE_PPT) {
415 if (option & UG_FILTER_CATEGORY_PDF) {
416 if (pnode_info->type == UG_FILE_TYPE_PDF) {
420 if (option & UG_FILTER_CATEGORY_TXT) {
421 if (pnode_info->type == UG_FILE_TYPE_TXT) {
425 if (option & UG_FILTER_CATEGORY_VCONTACT) {
426 if (pnode_info->type == UG_FILE_TYPE_VCONTACT) {
430 if (option & UG_FILTER_CATEGORY_VCALENDAR) {
431 if (pnode_info->type == UG_FILE_TYPE_VCALENDAR) {
435 if (option & UG_FILTER_CATEGORY_VNOTE) {
436 if (pnode_info->type == UG_FILE_TYPE_VNOTE) {
440 if (option & UG_FILTER_CATEGORY_VBOOKMARK) {
441 if (pnode_info->type == UG_FILE_TYPE_VBOOKMARK) {
445 if (option & UG_FILTER_CATEGORY_VIDEO_PROJECT) {
446 if (pnode_info->type == UG_FILE_TYPE_VIDEO_PROJECT) {
450 if (option & UG_FILTER_CATEGORY_SVG) {
451 if (pnode_info->type == UG_FILE_TYPE_SVG) {
455 if (option & UG_FILTER_CATEGORY_RSS) {
456 if (pnode_info->type == UG_FILE_TYPE_RSS) {
460 if (option & UG_FILTER_CATEGORY_ETC) {
461 if (pnode_info->type == UG_FILE_TYPE_ETC) {
468 int mf_ug_fs_oper_list_filter(Eina_List *in_list, Eina_List **out_list, int option, int drm_opt)
471 if (in_list == NULL) {
472 return MYFILE_ERR_SRC_ARG_INVALID;
475 if (out_list == NULL) {
476 return MYFILE_ERR_DST_ARG_INVALID;
481 return MYFILE_ERR_NONE;
485 ugFsNodeInfo *data = NULL;
486 EINA_LIST_FOREACH(in_list, l, data) {
487 if (data->type == UG_FILE_TYPE_DRM && __mf_ug_fs_oper_exec_drm_filter(data, drm_opt)) {
488 ug_debug("file [%s] is drm file", data->name);
489 *out_list = eina_list_append(*out_list, data);
490 } else if (__mf_ug_fs_oper_exec_filter(data, option)) {
491 *out_list = eina_list_append(*out_list, data);
494 return MYFILE_ERR_NONE;
497 /******************************
498 ** Prototype : ug_mf_list_filter_by_extention
499 ** Description : filter from list by extension
500 ** Input : Eina_List *in_list
501 ** Eina_List **out_list
509 ** 1.Date : 2010/12/10
511 ** Modification : Created function
513 ******************************/
514 int mf_ug_fs_oper_list_filter_by_extension(Eina_List *in_list, Eina_List **out_list, char *ext)
516 if (in_list == NULL) {
517 return MYFILE_ERR_SRC_ARG_INVALID;
520 if (out_list == NULL) {
521 return MYFILE_ERR_DST_ARG_INVALID;
526 return MYFILE_ERR_NONE;
530 ugFsNodeInfo *data = NULL;
533 char *temp_ext = malloc(strlen(ext) + 1);
534 gchar **result = NULL;
535 gchar **params = NULL;
537 EINA_LIST_FOREACH(in_list, l, data) {
538 memset(temp_ext, 0, strlen(ext) + 1);
539 strncpy(temp_ext, ext, strlen(ext));
540 result = g_strsplit(temp_ext, seps, 0);
541 if (result == NULL) {
544 for (params = result; *params; params++) {
545 if (data->ext == NULL)
547 if (strcasecmp(data->ext, *params) == 0) {
548 *out_list = eina_list_append(*out_list, data);
557 return MYFILE_ERR_NONE;
560 static int __mf_ug_fs_oper_sort_by_priority(const void *d1, const void *d2, int sequence_type)
563 switch(sequence_type) {
564 case MF_UG_SORT_BY_PRIORITY_TYPE_A2Z:
565 ret = __mf_ug_fs_oper_sort_by_date_cb_O2R(d1, d2);
567 ret = __mf_ug_fs_oper_sort_by_size_cb_S2L(d1, d2);
569 ret = __mf_ug_fs_oper_sort_by_name_cb_A2Z(d1, d2);
573 case MF_UG_SORT_BY_PRIORITY_TYPE_Z2A:
574 ret = __mf_ug_fs_oper_sort_by_date_cb_R2O(d1, d2);
576 ret = __mf_ug_fs_oper_sort_by_size_cb_L2S(d1, d2);
578 ret = __mf_ug_fs_oper_sort_by_name_cb_Z2A(d1, d2);
582 case MF_UG_SORT_BY_PRIORITY_DATE_O2R:
583 ret = __mf_ug_fs_oper_sort_by_size_cb_S2L(d1, d2);
585 ret = __mf_ug_fs_oper_sort_by_name_cb_A2Z(d1, d2);
588 case MF_UG_SORT_BY_PRIORITY_DATE_R2O:
589 ret = __mf_ug_fs_oper_sort_by_size_cb_L2S(d1, d2);
591 ret = __mf_ug_fs_oper_sort_by_name_cb_Z2A(d1, d2);
594 case MF_UG_SORT_BY_PRIORITY_SIZE_S2L:
595 ret = __mf_ug_fs_oper_sort_by_name_cb_A2Z(d1, d2);
597 case MF_UG_SORT_BY_PRIORITY_SIZE_L2S:
598 ret = __mf_ug_fs_oper_sort_by_name_cb_Z2A(d1, d2);
605 /*********************
606 **Function name: __sort_by_name_cb
608 ** const void *d1: node1 to compare
609 ** const void *d2: node2 to compare
617 ** sort the list order by the Assic table
620 *********************/
621 static int __mf_ug_fs_oper_sort_by_name_cb_A2Z(const void *d1, const void *d2)
623 ugFsNodeInfo *txt1 = (ugFsNodeInfo *) d1;
624 ugFsNodeInfo *txt2 = (ugFsNodeInfo *) d2;
636 name1 = g_ascii_strdown(txt1->name, strlen(txt1->name));
640 name2 = g_ascii_strdown(txt2->name, strlen(txt2->name));
646 result = g_strcmp0(name1, name2);
656 /*********************
657 **Function name: __sort_by_date_cb
659 ** const void *d1: node1 to compare
660 ** const void *d2: node2 to compare
668 ** sort the list order by the later created the later shown
669 *********************/
670 static int __mf_ug_fs_oper_sort_by_date_cb_O2R(const void *d1, const void *d2)
673 ugFsNodeInfo *time1 = (ugFsNodeInfo *) d1;
674 ugFsNodeInfo *time2 = (ugFsNodeInfo *) d2;
683 if (time1->date > time2->date) {
685 } else if (time1->date < time2->date) {
692 ret = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_DATE_O2R);
697 /*********************
698 **Function name: __sort_by_type_cb
700 ** const void *d1: node1 to compare
701 ** const void *d2: node2 to compare
709 ** sort the list order by the category type value
710 *********************/
711 static int __mf_ug_fs_oper_sort_by_type_cb_A2Z(const void *d1, const void *d2)
713 ugFsNodeInfo *type1 = (ugFsNodeInfo *) d1;
714 ugFsNodeInfo *type2 = (ugFsNodeInfo *) d2;
719 if (type1 == NULL || type1->ext == NULL) {
723 if (type2 == NULL || type2->ext == NULL) {
726 ext1 = g_ascii_strdown(type1->ext, strlen(type1->ext));
730 ext2 = g_ascii_strdown(type2->ext, strlen(type2->ext));
736 result = g_strcmp0(ext1, ext2);
744 result = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_TYPE_A2Z);
750 /*order: the one with smaller size will be shown earlier*/
751 /*********************
752 **Function name: __sort_by_name_cb
754 ** const void *d1: node1 to compare
755 ** const void *d2: node2 to compare
763 ** sort the list order by size, rule is the smaller the later shown
764 *********************/
765 static int __mf_ug_fs_oper_sort_by_size_cb_S2L(const void *d1, const void *d2)
768 ugFsNodeInfo *size1 = (ugFsNodeInfo *) d1;
769 ugFsNodeInfo *size2 = (ugFsNodeInfo *) d2;
779 if (size1->size > size2->size) {
781 } else if (size1->size < size2->size) {
788 ret = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_SIZE_S2L);
793 /*********************
794 **Function name: __mf_fs_oper_sort_by_name_cb_Z2A
796 ** const void *d1: node1 to compare
797 ** const void *d2: node2 to compare
804 ** sort the list order by the Assic table
807 *********************/
808 static int __mf_ug_fs_oper_sort_by_name_cb_Z2A(const void *d1, const void *d2)
810 ugFsNodeInfo *txt1 = (ugFsNodeInfo *) d1;
811 ugFsNodeInfo *txt2 = (ugFsNodeInfo *) d2;
821 result = strcasecmp(txt1->name, txt2->name);
830 /*********************
831 **Function name: __sort_by_date_cb
833 ** const void *d1: node1 to compare
834 ** const void *d2: node2 to compare
842 ** sort the list order by the later created the later shown
843 *********************/
844 static int __mf_ug_fs_oper_sort_by_date_cb_R2O(const void *d1, const void *d2)
847 ugFsNodeInfo *time1 = (ugFsNodeInfo *) d1;
848 ugFsNodeInfo *time2 = (ugFsNodeInfo *) d2;
856 if (time1->date > time2->date) {
858 } else if (time1->date < time2->date) {
865 ret = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_DATE_R2O);
870 /*********************
871 **Function name: __sort_by_type_cb
873 ** const void *d1: node1 to compare
874 ** const void *d2: node2 to compare
882 ** sort the list order by the category type value
883 *********************/
884 static int __mf_ug_fs_oper_sort_by_type_cb_Z2A(const void *d1, const void *d2)
886 ugFsNodeInfo *type1 = (ugFsNodeInfo *) d1;
887 ugFsNodeInfo *type2 = (ugFsNodeInfo *) d2;
892 if (type1 == NULL || type1->ext == NULL) {
896 if (type2 == NULL || type2->ext == NULL) {
900 ext1 = g_ascii_strdown(type1->ext, strlen(type1->ext));
904 ext2 = g_ascii_strdown(type2->ext, strlen(type2->ext));
910 result = g_strcmp0(ext1, ext2);
916 result = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_TYPE_Z2A);
922 /*order: the one with smaller size will be shown earlier*/
923 /*********************
924 **Function name: __sort_by_name_cb
926 ** const void *d1: node1 to compare
927 ** const void *d2: node2 to compare
935 ** sort the list order by size, rule is the smaller the later shown
936 *********************/
937 static int __mf_ug_fs_oper_sort_by_size_cb_L2S(const void *d1, const void *d2)
940 ugFsNodeInfo *size1 = (ugFsNodeInfo *) d1;
941 ugFsNodeInfo *size2 = (ugFsNodeInfo *) d2;
951 if (size1->size > size2->size) {
953 } else if (size1->size < size2->size) {
960 ret = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_SIZE_L2S);
965 /*********************
966 **Function name: mf_fs_oper_sort_list
968 ** Eina_List **list: the list we need to sort
969 ** int sort_opt: sort option
975 ** sort the list order by sort option with the call back
976 *********************/
977 void mf_ug_fs_oper_sort_list(Eina_List **list, int sort_opt)
979 Eina_Compare_Cb sort_func = NULL;
984 case MF_UG_SORT_BY_NAME_A2Z:
985 sort_func = __mf_ug_fs_oper_sort_by_name_cb_A2Z;
987 case MF_UG_SORT_BY_TYPE_A2Z:
988 sort_func = __mf_ug_fs_oper_sort_by_type_cb_A2Z;
990 case MF_UG_SORT_BY_SIZE_S2L:
991 sort_func = __mf_ug_fs_oper_sort_by_size_cb_S2L;
993 case MF_UG_SORT_BY_DATE_O2R:
994 sort_func = __mf_ug_fs_oper_sort_by_date_cb_O2R;
996 case MF_UG_SORT_BY_NAME_Z2A:
997 sort_func = __mf_ug_fs_oper_sort_by_name_cb_Z2A;
999 case MF_UG_SORT_BY_TYPE_Z2A:
1000 sort_func = __mf_ug_fs_oper_sort_by_type_cb_Z2A;
1002 case MF_UG_SORT_BY_SIZE_L2S:
1003 sort_func = __mf_ug_fs_oper_sort_by_size_cb_L2S;
1005 case MF_UG_SORT_BY_DATE_R2O:
1006 sort_func = __mf_ug_fs_oper_sort_by_date_cb_R2O;
1009 sort_func = __mf_ug_fs_oper_sort_by_type_cb_A2Z;
1012 *list = eina_list_sort(*list, eina_list_count(*list), sort_func);
1015 int mf_ug_fs_oper_create_dir(const char *dir)
1017 int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_DUPLICATED;
1018 int ret = __mf_ug_fs_oper_file_system_error(dir, dir, option);
1024 ret = mf_ug_file_attr_is_right_dir_path(dir);
1030 mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
1032 if (mkdir(dir, default_mode) < 0) {
1033 return MYFILE_ERR_DIR_CREATE_FAIL;
1035 return MYFILE_ERR_NONE;