diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2012-09-19 06:44:39 +0000 |
---|---|---|
committer | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2012-09-19 06:44:39 +0000 |
commit | ad7cd0677e2e223f964add40a13e420118b9a102 (patch) | |
tree | 97045d71bd68f284875c0a81659d9e46b54146f7 /src/bin/e_path.c | |
parent | bb71414d4d67a8e3b8f23e60b96e501ecffad906 (diff) |
formatting
SVN revision: 76842
Diffstat (limited to '')
-rw-r--r-- | src/bin/e_path.c | 333 |
1 files changed, 167 insertions, 166 deletions
diff --git a/src/bin/e_path.c b/src/bin/e_path.c index fb7ec50..64eea23 100644 --- a/src/bin/e_path.c +++ b/src/bin/e_path.c | |||
@@ -24,36 +24,36 @@ e_path_default_path_append(E_Path *ep, const char *path) | |||
24 | if (path[0] == '~') | 24 | if (path[0] == '~') |
25 | { | 25 | { |
26 | E_Path_Dir *epd; | 26 | E_Path_Dir *epd; |
27 | char *new_path; | 27 | char *new_path; |
28 | const char *home_dir; | 28 | const char *home_dir; |
29 | int len1, len2; | 29 | int len1, len2; |
30 | 30 | ||
31 | home_dir = e_user_homedir_get(); | 31 | home_dir = e_user_homedir_get(); |
32 | len1 = strlen(home_dir); | 32 | len1 = strlen(home_dir); |
33 | len2 = strlen(path); | 33 | len2 = strlen(path); |
34 | new_path = malloc(len1 + len2 + 1); | 34 | new_path = malloc(len1 + len2 + 1); |
35 | if (!new_path) return; | 35 | if (!new_path) return; |
36 | epd = malloc(sizeof(E_Path_Dir)); | 36 | epd = malloc(sizeof(E_Path_Dir)); |
37 | if (!epd) | 37 | if (!epd) |
38 | { | 38 | { |
39 | free(new_path); | 39 | free(new_path); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | 42 | ||
43 | strcpy(new_path, home_dir); | 43 | strcpy(new_path, home_dir); |
44 | strcat(new_path, path + 1); | 44 | strcat(new_path, path + 1); |
45 | epd->dir = eina_stringshare_add(new_path); | 45 | epd->dir = eina_stringshare_add(new_path); |
46 | free(new_path); | 46 | free(new_path); |
47 | ep->default_dir_list = eina_list_append(ep->default_dir_list, epd); | 47 | ep->default_dir_list = eina_list_append(ep->default_dir_list, epd); |
48 | } | 48 | } |
49 | else | 49 | else |
50 | { | 50 | { |
51 | E_Path_Dir *epd; | 51 | E_Path_Dir *epd; |
52 | epd = malloc(sizeof(E_Path_Dir)); | 52 | epd = malloc(sizeof(E_Path_Dir)); |
53 | if (!epd) | 53 | if (!epd) |
54 | return; | 54 | return; |
55 | epd->dir = eina_stringshare_add(path); | 55 | epd->dir = eina_stringshare_add(path); |
56 | ep->default_dir_list = eina_list_append(ep->default_dir_list, epd); | 56 | ep->default_dir_list = eina_list_append(ep->default_dir_list, epd); |
57 | } | 57 | } |
58 | _e_path_cache_free(ep); | 58 | _e_path_cache_free(ep); |
59 | } | 59 | } |
@@ -77,36 +77,36 @@ e_path_user_path_append(E_Path *ep, const char *path) | |||
77 | if (path[0] == '~') | 77 | if (path[0] == '~') |
78 | { | 78 | { |
79 | E_Path_Dir *epd; | 79 | E_Path_Dir *epd; |
80 | char *new_path; | 80 | char *new_path; |
81 | const char *home_dir; | 81 | const char *home_dir; |
82 | int len1, len2; | 82 | int len1, len2; |
83 | 83 | ||
84 | home_dir = e_user_homedir_get(); | 84 | home_dir = e_user_homedir_get(); |
85 | len1 = strlen(home_dir); | 85 | len1 = strlen(home_dir); |
86 | len2 = strlen(path); | 86 | len2 = strlen(path); |
87 | new_path = malloc(len1 + len2 + 1); | 87 | new_path = malloc(len1 + len2 + 1); |
88 | if (!new_path) return; | 88 | if (!new_path) return; |
89 | epd = malloc(sizeof(E_Path_Dir)); | 89 | epd = malloc(sizeof(E_Path_Dir)); |
90 | if (!epd) | 90 | if (!epd) |
91 | { | 91 | { |
92 | free(new_path); | 92 | free(new_path); |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | 95 | ||
96 | strcpy(new_path, home_dir); | 96 | strcpy(new_path, home_dir); |
97 | strcat(new_path, path + 1); | 97 | strcat(new_path, path + 1); |
98 | epd->dir = eina_stringshare_add(new_path); | 98 | epd->dir = eina_stringshare_add(new_path); |
99 | free(new_path); | 99 | free(new_path); |
100 | *(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd); | 100 | *(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd); |
101 | } | 101 | } |
102 | else | 102 | else |
103 | { | 103 | { |
104 | E_Path_Dir *epd; | 104 | E_Path_Dir *epd; |
105 | epd = malloc(sizeof(E_Path_Dir)); | 105 | epd = malloc(sizeof(E_Path_Dir)); |
106 | if (!epd) | 106 | if (!epd) |
107 | return; | 107 | return; |
108 | epd->dir = eina_stringshare_add(path); | 108 | epd->dir = eina_stringshare_add(path); |
109 | *(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd); | 109 | *(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd); |
110 | } | 110 | } |
111 | _e_path_cache_free(ep); | 111 | _e_path_cache_free(ep); |
112 | } | 112 | } |
@@ -120,36 +120,36 @@ e_path_user_path_prepend(E_Path *ep, const char *path) | |||
120 | if (path[0] == '~') | 120 | if (path[0] == '~') |
121 | { | 121 | { |
122 | E_Path_Dir *epd; | 122 | E_Path_Dir *epd; |
123 | char *new_path; | 123 | char *new_path; |
124 | const char *home_dir; | 124 | const char *home_dir; |
125 | int len1, len2; | 125 | int len1, len2; |
126 | 126 | ||
127 | home_dir = e_user_homedir_get(); | 127 | home_dir = e_user_homedir_get(); |
128 | len1 = strlen(home_dir); | 128 | len1 = strlen(home_dir); |
129 | len2 = strlen(path); | 129 | len2 = strlen(path); |
130 | new_path = malloc(len1 + len2 + 1); | 130 | new_path = malloc(len1 + len2 + 1); |
131 | if (!new_path) return; | 131 | if (!new_path) return; |
132 | epd = malloc(sizeof(E_Path_Dir)); | 132 | epd = malloc(sizeof(E_Path_Dir)); |
133 | if (!epd) | 133 | if (!epd) |
134 | { | 134 | { |
135 | free(new_path); | 135 | free(new_path); |
136 | return; | 136 | return; |
137 | } | 137 | } |
138 | 138 | ||
139 | strcpy(new_path, home_dir); | 139 | strcpy(new_path, home_dir); |
140 | strcat(new_path, path + 1); | 140 | strcat(new_path, path + 1); |
141 | epd->dir = eina_stringshare_add(new_path); | 141 | epd->dir = eina_stringshare_add(new_path); |
142 | free(new_path); | 142 | free(new_path); |
143 | *(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd); | 143 | *(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd); |
144 | } | 144 | } |
145 | else | 145 | else |
146 | { | 146 | { |
147 | E_Path_Dir *epd; | 147 | E_Path_Dir *epd; |
148 | epd = malloc(sizeof(E_Path_Dir)); | 148 | epd = malloc(sizeof(E_Path_Dir)); |
149 | if (!epd) | 149 | if (!epd) |
150 | return; | 150 | return; |
151 | epd->dir = eina_stringshare_add(path); | 151 | epd->dir = eina_stringshare_add(path); |
152 | *(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd); | 152 | *(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd); |
153 | } | 153 | } |
154 | _e_path_cache_free(ep); | 154 | _e_path_cache_free(ep); |
155 | } | 155 | } |
@@ -165,52 +165,52 @@ e_path_user_path_remove(E_Path *ep, const char *path) | |||
165 | if (!path) return; | 165 | if (!path) return; |
166 | if (path[0] == '~') | 166 | if (path[0] == '~') |
167 | { | 167 | { |
168 | char *new_path; | 168 | char *new_path; |
169 | const char *home_dir; | 169 | const char *home_dir; |
170 | int len1, len2; | 170 | int len1, len2; |
171 | 171 | ||
172 | home_dir = e_user_homedir_get(); | 172 | home_dir = e_user_homedir_get(); |
173 | len1 = strlen(home_dir); | 173 | len1 = strlen(home_dir); |
174 | len2 = strlen(path); | 174 | len2 = strlen(path); |
175 | new_path = malloc(len1 + len2 + 1); | 175 | new_path = malloc(len1 + len2 + 1); |
176 | if (!new_path) return; | 176 | if (!new_path) return; |
177 | strcpy(new_path, home_dir); | 177 | strcpy(new_path, home_dir); |
178 | strcat(new_path, path + 1); | 178 | strcat(new_path, path + 1); |
179 | EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) | 179 | EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) |
180 | { | 180 | { |
181 | if (epd->dir) | 181 | if (epd->dir) |
182 | { | 182 | { |
183 | if (!strcmp(epd->dir, new_path)) | 183 | if (!strcmp(epd->dir, new_path)) |
184 | { | 184 | { |
185 | *(ep->user_dir_list) = eina_list_remove_list( | 185 | *(ep->user_dir_list) = eina_list_remove_list( |
186 | *(ep->user_dir_list), l); | 186 | *(ep->user_dir_list), l); |
187 | eina_stringshare_del(epd->dir); | 187 | eina_stringshare_del(epd->dir); |
188 | free(epd); | 188 | free(epd); |
189 | free(new_path); | 189 | free(new_path); |
190 | _e_path_cache_free(ep); | 190 | _e_path_cache_free(ep); |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | } | 194 | } |
195 | free(new_path); | 195 | free(new_path); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) | 199 | EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) |
200 | { | 200 | { |
201 | if (epd->dir) | 201 | if (epd->dir) |
202 | { | 202 | { |
203 | if (!strcmp(epd->dir, path)) | 203 | if (!strcmp(epd->dir, path)) |
204 | { | 204 | { |
205 | *(ep->user_dir_list) = eina_list_remove_list( | 205 | *(ep->user_dir_list) = eina_list_remove_list( |
206 | *(ep->user_dir_list), l); | 206 | *(ep->user_dir_list), l); |
207 | eina_stringshare_del(epd->dir); | 207 | eina_stringshare_del(epd->dir); |
208 | free(epd); | 208 | free(epd); |
209 | _e_path_cache_free(ep); | 209 | _e_path_cache_free(ep); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | } | 212 | } |
213 | } | 213 | } |
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
@@ -220,8 +220,8 @@ e_path_user_path_clear(E_Path *ep) | |||
220 | E_Path_Dir *epd; | 220 | E_Path_Dir *epd; |
221 | EINA_LIST_FREE(*(ep->user_dir_list), epd) | 221 | EINA_LIST_FREE(*(ep->user_dir_list), epd) |
222 | { | 222 | { |
223 | eina_stringshare_del(epd->dir); | 223 | eina_stringshare_del(epd->dir); |
224 | free(epd); | 224 | free(epd); |
225 | } | 225 | } |
226 | _e_path_cache_free(ep); | 226 | _e_path_cache_free(ep); |
227 | } | 227 | } |
@@ -243,38 +243,38 @@ e_path_find(E_Path *ep, const char *file) | |||
243 | /* Look in the default dir list */ | 243 | /* Look in the default dir list */ |
244 | EINA_LIST_FOREACH(ep->default_dir_list, l, epd) | 244 | EINA_LIST_FOREACH(ep->default_dir_list, l, epd) |
245 | { | 245 | { |
246 | if (epd->dir) | 246 | if (epd->dir) |
247 | { | 247 | { |
248 | snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file); | 248 | snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file); |
249 | if (ecore_file_exists(buf)) | 249 | if (ecore_file_exists(buf)) |
250 | { | 250 | { |
251 | if (!ep->hash) | 251 | if (!ep->hash) |
252 | ep->hash = eina_hash_string_superfast_new(NULL); | 252 | ep->hash = eina_hash_string_superfast_new(NULL); |
253 | if (eina_hash_population(ep->hash) >= 512) | 253 | if (eina_hash_population(ep->hash) >= 512) |
254 | _e_path_cache_free(ep); | 254 | _e_path_cache_free(ep); |
255 | eina_hash_add(ep->hash, file, | 255 | eina_hash_add(ep->hash, file, |
256 | eina_stringshare_add(buf)); | 256 | eina_stringshare_add(buf)); |
257 | return eina_stringshare_add(buf); | 257 | return eina_stringshare_add(buf); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | /* Look in the users dir list */ | 261 | /* Look in the users dir list */ |
262 | EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) | 262 | EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) |
263 | { | 263 | { |
264 | if (epd->dir) | 264 | if (epd->dir) |
265 | { | 265 | { |
266 | snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file); | 266 | snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file); |
267 | if (ecore_file_exists(buf)) | 267 | if (ecore_file_exists(buf)) |
268 | { | 268 | { |
269 | if (!ep->hash) | 269 | if (!ep->hash) |
270 | ep->hash = eina_hash_string_superfast_new(NULL); | 270 | ep->hash = eina_hash_string_superfast_new(NULL); |
271 | if (eina_hash_population(ep->hash) >= 512) | 271 | if (eina_hash_population(ep->hash) >= 512) |
272 | _e_path_cache_free(ep); | 272 | _e_path_cache_free(ep); |
273 | eina_hash_add(ep->hash, file, | 273 | eina_hash_add(ep->hash, file, |
274 | eina_stringshare_add(buf)); | 274 | eina_stringshare_add(buf)); |
275 | return eina_stringshare_add(buf); | 275 | return eina_stringshare_add(buf); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | } | 278 | } |
279 | return NULL; | 279 | return NULL; |
280 | } | 280 | } |
@@ -293,9 +293,9 @@ e_path_evas_append(E_Path *ep, Evas *evas) | |||
293 | 293 | ||
294 | EINA_LIST_FREE(dir_list, epd) | 294 | EINA_LIST_FREE(dir_list, epd) |
295 | { | 295 | { |
296 | if (epd->dir) evas_font_path_append(evas, epd->dir); | 296 | if (epd->dir) evas_font_path_append(evas, epd->dir); |
297 | eina_stringshare_del(epd->dir); | 297 | eina_stringshare_del(epd->dir); |
298 | free(epd); | 298 | free(epd); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
@@ -303,28 +303,28 @@ e_path_evas_append(E_Path *ep, Evas *evas) | |||
303 | EAPI Eina_List * | 303 | EAPI Eina_List * |
304 | e_path_dir_list_get(E_Path *ep) | 304 | e_path_dir_list_get(E_Path *ep) |
305 | { | 305 | { |
306 | Eina_List *dir_list; | 306 | Eina_List *dir_list; |
307 | Eina_List *l; | 307 | Eina_List *l; |
308 | E_Path_Dir *new_epd; | 308 | E_Path_Dir *new_epd; |
309 | E_Path_Dir *epd; | 309 | E_Path_Dir *epd; |
310 | 310 | ||
311 | dir_list = NULL; | 311 | dir_list = NULL; |
312 | 312 | ||
313 | if (ep->user_dir_list) | 313 | if (ep->user_dir_list) |
314 | { | 314 | { |
315 | EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) | 315 | EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) |
316 | { | 316 | { |
317 | new_epd = malloc(sizeof(E_Path_Dir)); | 317 | new_epd = malloc(sizeof(E_Path_Dir)); |
318 | new_epd->dir = eina_stringshare_add(epd->dir); | 318 | new_epd->dir = eina_stringshare_add(epd->dir); |
319 | dir_list = eina_list_append(dir_list, new_epd); | 319 | dir_list = eina_list_append(dir_list, new_epd); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | EINA_LIST_FOREACH(ep->default_dir_list, l, epd) | 323 | EINA_LIST_FOREACH(ep->default_dir_list, l, epd) |
324 | { | 324 | { |
325 | new_epd = malloc(sizeof(E_Path_Dir)); | 325 | new_epd = malloc(sizeof(E_Path_Dir)); |
326 | new_epd->dir = eina_stringshare_add(epd->dir); | 326 | new_epd->dir = eina_stringshare_add(epd->dir); |
327 | dir_list = eina_list_append(dir_list, new_epd); | 327 | dir_list = eina_list_append(dir_list, new_epd); |
328 | } | 328 | } |
329 | 329 | ||
330 | return dir_list; | 330 | return dir_list; |
@@ -337,8 +337,8 @@ e_path_dir_list_free(Eina_List *dir_list) | |||
337 | 337 | ||
338 | EINA_LIST_FREE(dir_list, epd) | 338 | EINA_LIST_FREE(dir_list, epd) |
339 | { | 339 | { |
340 | eina_stringshare_del(epd->dir); | 340 | eina_stringshare_del(epd->dir); |
341 | free(epd); | 341 | free(epd); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
@@ -351,8 +351,8 @@ _e_path_free(E_Path *ep) | |||
351 | _e_path_cache_free(ep); | 351 | _e_path_cache_free(ep); |
352 | EINA_LIST_FREE(ep->default_dir_list, epd) | 352 | EINA_LIST_FREE(ep->default_dir_list, epd) |
353 | { | 353 | { |
354 | eina_stringshare_del(epd->dir); | 354 | eina_stringshare_del(epd->dir); |
355 | free(epd); | 355 | free(epd); |
356 | } | 356 | } |
357 | free(ep); | 357 | free(ep); |
358 | } | 358 | } |
@@ -372,3 +372,4 @@ _e_path_cache_free_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED | |||
372 | eina_stringshare_del(data); | 372 | eina_stringshare_del(data); |
373 | return 1; | 373 | return 1; |
374 | } | 374 | } |
375 | |||