File Manager / inc / utils /

model-utils.h

  1. /*
  2. * Copyright 2014 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (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
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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.
  15. *
  16. */
  17.  
  18. #ifndef MODEL_UTILS_H_
  19. #define MODEL_UTILS_H_
  20.  
  21. #include "utils/app-types.h"
  22.  
  23. #define DIR_MODE S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
  24.  
  25. /**
  26. * @brief Check wheather filepath is right
  27. * @param[in] fullpath Full path of checked file/folder
  28. * @param[in] is_dir Flag if checked file path is dir
  29. * @return Error code. RESULT_TYPE_OK if file path is correct
  30. * RESULT_TYPE_INVALID_PATH if file path is invalid
  31. */
  32. int model_utils_is_path_valid(const char *fullpath, Eina_Bool is_dir);
  33.  
  34. /**
  35. * @brief Check if file exists
  36. * @param[in] filepath Path to file
  37. * @return EINA_TRUE if file exists
  38. * EINA_FALSE if file does not exist
  39. */
  40. Eina_Bool model_utils_is_file_exists(const char *filepath);
  41.  
  42. /**
  43. * @brief Check if file is a directory
  44. * @param[in] filepath Path to file
  45. * @return EINA_TRUE if file exist and is a directory
  46. * EINA_FALSE if file does not exist
  47. */
  48. Eina_Bool model_utils_file_is_dir(const char *filepath);
  49.  
  50. /**
  51. * @brief Get the directory where file reside
  52. * @param[in] filepath Path to file
  53. * @return The directory name
  54. */
  55. char* model_utils_get_dir_name(const char *filepath);
  56.  
  57. /**
  58. * @brief Get file category by file path
  59. * @param[in] filepath Path to file
  60. * @param[out] category Type of file category
  61. * @return Error code. RESULT_TYPE_OK if file path is correct
  62. * RESULT_TYPE_INVALID_PATH if file path is invalid
  63. * RESULT_TYPE_FAIL if failed to get file type
  64. */
  65. int model_utils_get_file_category(const char *filepath, file_type *category);
  66.  
  67. /**
  68. * @brief Get icon resource name for file type
  69. * @param[in] ftype File type
  70. * @return resource name of the icon
  71. */
  72. const char *model_utils_get_default_icon_name(file_type ftype);
  73.  
  74. /**
  75. * @brief Get type of storage
  76. * @param[in] fullpath Full path to file/dir
  77. * @return type of storage where file/dir is located
  78. */
  79. storage_type model_utils_get_storage_type(const char *fullpath);
  80.  
  81. /**
  82. * @brief Get "public" path to file/dir (hide real device file path)
  83. * @param[in] original_path Real full path to file/dir
  84. * @return public file path to file/dir
  85. */
  86. char *model_utils_get_public_file_path(const char *original_path);
  87.  
  88. /**
  89. * @brief Check if path is a root path of storage
  90. * @param[in] fullpath Path to check
  91. * @return Storage type. Result will be STORAGE_TYPE_NONE if checked path is not a root
  92. */
  93. storage_type model_utils_is_root_path(const char *fullpath);
  94.  
  95. /**
  96. * @brief Launch service to view file content
  97. * @param[in] file_info File info
  98. * @return Error code. RESULT_TYPE_OK if operation success
  99. */
  100. int model_utils_launch_file(const node_info *file_info);
  101.  
  102. /**
  103. * @brief Reads directory and fills two lists with node_info structures
  104. * @param[in] dir_path Path to the directory to read
  105. * @param[in/out] dir_list List to append node_info of the sub directories
  106. * @param[in/out] file_list List to append node_info of files
  107. * @return Error code. RESULT_TYPE_OK if operation success
  108. */
  109. int model_utils_read_dir(const char *dir_path, Eina_List **dir_list, Eina_List **file_list);
  110.  
  111. char *model_utils_get_phone_path(void);
  112.  
  113. #endif /* MODEL_UTILS_H_ */