diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_file/Ecore_File.h | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_file/Ecore_File.h b/libraries/ecore/src/lib/ecore_file/Ecore_File.h new file mode 100644 index 0000000..e4b8851 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_file/Ecore_File.h | |||
@@ -0,0 +1,190 @@ | |||
1 | #ifndef ECORE_FILE_H | ||
2 | #define ECORE_FILE_H | ||
3 | |||
4 | /* | ||
5 | * TODO: | ||
6 | * - More events, move/rename of directory file | ||
7 | */ | ||
8 | |||
9 | #include <Eina.h> | ||
10 | |||
11 | #ifdef EAPI | ||
12 | # undef EAPI | ||
13 | #endif | ||
14 | |||
15 | #ifdef _WIN32 | ||
16 | # ifdef EFL_ECORE_FILE_BUILD | ||
17 | # ifdef DLL_EXPORT | ||
18 | # define EAPI __declspec(dllexport) | ||
19 | # else | ||
20 | # define EAPI | ||
21 | # endif /* ! DLL_EXPORT */ | ||
22 | # else | ||
23 | # define EAPI __declspec(dllimport) | ||
24 | # endif /* ! EFL_ECORE_FILE_BUILD */ | ||
25 | #else | ||
26 | # ifdef __GNUC__ | ||
27 | # if __GNUC__ >= 4 | ||
28 | # define EAPI __attribute__ ((visibility("default"))) | ||
29 | # else | ||
30 | # define EAPI | ||
31 | # endif | ||
32 | # else | ||
33 | # define EAPI | ||
34 | # endif | ||
35 | #endif /* ! _WIN32 */ | ||
36 | |||
37 | /** | ||
38 | * @file Ecore_File.h | ||
39 | * @brief Files utility functions | ||
40 | */ | ||
41 | |||
42 | #ifdef __cplusplus | ||
43 | extern "C" { | ||
44 | #endif | ||
45 | |||
46 | /** | ||
47 | * @defgroup Ecore_File_Group Ecore_File - Files and directories convenience functions | ||
48 | * | ||
49 | * @{ | ||
50 | */ | ||
51 | |||
52 | /** | ||
53 | * @typedef Ecore_File_Monitor | ||
54 | * Abstract type used when monitoring a directory. | ||
55 | */ | ||
56 | typedef struct _Ecore_File_Monitor Ecore_File_Monitor; | ||
57 | |||
58 | /** | ||
59 | * @typedef Ecore_File_Download_Job | ||
60 | * Abstract type used when aborting a download. | ||
61 | */ | ||
62 | typedef struct _Ecore_File_Download_Job Ecore_File_Download_Job; | ||
63 | |||
64 | /** | ||
65 | * @typedef Ecore_File_Event | ||
66 | * The event type returned when a file or directory is monitored. | ||
67 | */ | ||
68 | typedef enum _Ecore_File_Event | ||
69 | { | ||
70 | ECORE_FILE_EVENT_NONE, /**< No event. */ | ||
71 | ECORE_FILE_EVENT_CREATED_FILE, /**< Created file event. */ | ||
72 | ECORE_FILE_EVENT_CREATED_DIRECTORY, /**< Created directory event. */ | ||
73 | ECORE_FILE_EVENT_DELETED_FILE, /**< Deleted file event. */ | ||
74 | ECORE_FILE_EVENT_DELETED_DIRECTORY, /**< Deleted directory event. */ | ||
75 | ECORE_FILE_EVENT_DELETED_SELF, /**< Deleted monitored directory event. */ | ||
76 | ECORE_FILE_EVENT_MODIFIED, /**< Modified file or directory event. */ | ||
77 | ECORE_FILE_EVENT_CLOSED /**< Closed file event */ | ||
78 | } Ecore_File_Event; | ||
79 | |||
80 | /** | ||
81 | * @typedef Ecore_File_Monitor_Cb | ||
82 | * Callback type used when a monitored directory has changes. | ||
83 | */ | ||
84 | typedef void (*Ecore_File_Monitor_Cb)(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path); | ||
85 | |||
86 | /** | ||
87 | * @typedef Ecore_File_Download_Completion_Cb | ||
88 | * Callback type used when a download is finished. | ||
89 | */ | ||
90 | typedef void (*Ecore_File_Download_Completion_Cb)(void *data, const char *file, int status); | ||
91 | |||
92 | /** | ||
93 | * @typedef Ecore_File_Progress_Return | ||
94 | * What to do with the download as a return from the | ||
95 | * Ecore_File_Download_Progress_Cb function, if provided. | ||
96 | */ | ||
97 | typedef enum _Ecore_File_Progress_Return | ||
98 | { | ||
99 | ECORE_FILE_PROGRESS_CONTINUE = 0, /**< Continue the download. */ | ||
100 | ECORE_FILE_PROGRESS_ABORT = 1 /**< Abort the download. */ | ||
101 | } Ecore_File_Progress_Return; | ||
102 | |||
103 | /** | ||
104 | * @typedef Ecore_File_Download_Progress_Cb | ||
105 | * Callback type used while a download is in progress. | ||
106 | */ | ||
107 | typedef int (*Ecore_File_Download_Progress_Cb)(void *data, | ||
108 | const char *file, | ||
109 | long int dltotal, | ||
110 | long int dlnow, | ||
111 | long int ultotal, | ||
112 | long int ulnow); | ||
113 | |||
114 | /* File operations */ | ||
115 | |||
116 | EAPI int ecore_file_init (void); | ||
117 | EAPI int ecore_file_shutdown (void); | ||
118 | EAPI long long ecore_file_mod_time (const char *file); | ||
119 | EAPI long long ecore_file_size (const char *file); | ||
120 | EAPI Eina_Bool ecore_file_exists (const char *file); | ||
121 | EAPI Eina_Bool ecore_file_is_dir (const char *file); | ||
122 | EAPI Eina_Bool ecore_file_mkdir (const char *dir); | ||
123 | EAPI int ecore_file_mkdirs (const char **dirs); | ||
124 | EAPI int ecore_file_mksubdirs (const char *base, const char **subdirs); | ||
125 | EAPI Eina_Bool ecore_file_rmdir (const char *dir); | ||
126 | EAPI Eina_Bool ecore_file_recursive_rm (const char *dir); | ||
127 | EAPI Eina_Bool ecore_file_mkpath (const char *path); | ||
128 | EAPI int ecore_file_mkpaths (const char **paths); | ||
129 | EAPI Eina_Bool ecore_file_cp (const char *src, const char *dst); | ||
130 | EAPI Eina_Bool ecore_file_mv (const char *src, const char *dst); | ||
131 | EAPI Eina_Bool ecore_file_symlink (const char *src, const char *dest); | ||
132 | EAPI char *ecore_file_realpath (const char *file); | ||
133 | EAPI Eina_Bool ecore_file_unlink (const char *file); | ||
134 | EAPI Eina_Bool ecore_file_remove (const char *file); | ||
135 | EAPI const char *ecore_file_file_get (const char *path); | ||
136 | EAPI char *ecore_file_dir_get (const char *path); | ||
137 | EAPI Eina_Bool ecore_file_can_read (const char *file); | ||
138 | EAPI Eina_Bool ecore_file_can_write (const char *file); | ||
139 | EAPI Eina_Bool ecore_file_can_exec (const char *file); | ||
140 | EAPI char *ecore_file_readlink (const char *link); | ||
141 | EAPI Eina_List *ecore_file_ls (const char *dir); | ||
142 | EAPI Eina_Iterator *ecore_file_ls_iterator (const char *dir); | ||
143 | EAPI char *ecore_file_app_exe_get (const char *app); | ||
144 | EAPI char *ecore_file_escape_name (const char *filename); | ||
145 | EAPI char *ecore_file_strip_ext (const char *file); | ||
146 | EAPI int ecore_file_dir_is_empty (const char *dir); | ||
147 | |||
148 | /* Monitoring */ | ||
149 | |||
150 | EAPI Ecore_File_Monitor *ecore_file_monitor_add(const char *path, | ||
151 | Ecore_File_Monitor_Cb func, | ||
152 | void *data); | ||
153 | EAPI void ecore_file_monitor_del(Ecore_File_Monitor *ecore_file_monitor); | ||
154 | EAPI const char *ecore_file_monitor_path_get(Ecore_File_Monitor *ecore_file_monitor); | ||
155 | |||
156 | /* Path */ | ||
157 | |||
158 | EAPI Eina_Bool ecore_file_path_dir_exists(const char *in_dir); | ||
159 | EAPI Eina_Bool ecore_file_app_installed(const char *exe); | ||
160 | EAPI Eina_List *ecore_file_app_list(void); | ||
161 | |||
162 | /* Download */ | ||
163 | |||
164 | EAPI Eina_Bool ecore_file_download(const char *url, | ||
165 | const char *dst, | ||
166 | Ecore_File_Download_Completion_Cb completion_cb, | ||
167 | Ecore_File_Download_Progress_Cb progress_cb, | ||
168 | void *data, | ||
169 | Ecore_File_Download_Job **job_ret); | ||
170 | EAPI Eina_Bool ecore_file_download_full(const char *url, | ||
171 | const char *dst, | ||
172 | Ecore_File_Download_Completion_Cb completion_cb, | ||
173 | Ecore_File_Download_Progress_Cb progress_cb, | ||
174 | void *data, | ||
175 | Ecore_File_Download_Job **job_ret, | ||
176 | Eina_Hash *headers); | ||
177 | |||
178 | EAPI void ecore_file_download_abort_all(void); | ||
179 | EAPI void ecore_file_download_abort(Ecore_File_Download_Job *job); | ||
180 | EAPI Eina_Bool ecore_file_download_protocol_available(const char *protocol); | ||
181 | |||
182 | /** | ||
183 | * @} | ||
184 | */ | ||
185 | |||
186 | #ifdef __cplusplus | ||
187 | } | ||
188 | #endif | ||
189 | |||
190 | #endif | ||