diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/disktidy.c | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c index c06afeac70..dd75408d48 100644 --- a/apps/plugins/disktidy.c +++ b/apps/plugins/disktidy.c | |||
@@ -35,7 +35,8 @@ enum tidy_system | |||
35 | { | 35 | { |
36 | TIDY_MAC = 0, | 36 | TIDY_MAC = 0, |
37 | TIDY_WIN = 1, | 37 | TIDY_WIN = 1, |
38 | TIDY_BOTH = 2, | 38 | TIDY_NIX = 2, |
39 | TIDY_ALL = 3, | ||
39 | }; | 40 | }; |
40 | 41 | ||
41 | /* variable button definitions */ | 42 | /* variable button definitions */ |
@@ -145,9 +146,9 @@ enum tidy_return tidy_removedir(const char *name, int *removed) | |||
145 | return TIDY_RETURN_ABORT; | 146 | return TIDY_RETURN_ABORT; |
146 | } | 147 | } |
147 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) | 148 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) |
148 | { | 149 | { |
149 | rb->closedir(dir); | 150 | rb->closedir(dir); |
150 | return TIDY_RETURN_USB; | 151 | return TIDY_RETURN_USB; |
151 | } | 152 | } |
152 | 153 | ||
153 | rb->yield(); | 154 | rb->yield(); |
@@ -213,9 +214,9 @@ enum tidy_return tidy_clean(const char *name, int *removed, \ | |||
213 | return TIDY_RETURN_ABORT; | 214 | return TIDY_RETURN_ABORT; |
214 | } | 215 | } |
215 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) | 216 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) |
216 | { | 217 | { |
217 | rb->closedir(dir); | 218 | rb->closedir(dir); |
218 | return TIDY_RETURN_USB; | 219 | return TIDY_RETURN_USB; |
219 | } | 220 | } |
220 | 221 | ||
221 | rb->yield(); | 222 | rb->yield(); |
@@ -234,7 +235,7 @@ enum tidy_return tidy_clean(const char *name, int *removed, \ | |||
234 | /* check if we are in root directory "/" */ | 235 | /* check if we are in root directory "/" */ |
235 | if (rb->strcmp(name, "/") == 0) | 236 | if (rb->strcmp(name, "/") == 0) |
236 | { | 237 | { |
237 | if ((system == TIDY_MAC) || (system == TIDY_BOTH)) | 238 | if ((system == TIDY_MAC) || (system == TIDY_ALL)) |
238 | { | 239 | { |
239 | /* mac directories */ | 240 | /* mac directories */ |
240 | if (rb->strcmp(entry->d_name, ".Trashes") == 0) | 241 | if (rb->strcmp(entry->d_name, ".Trashes") == 0) |
@@ -247,7 +248,7 @@ enum tidy_return tidy_clean(const char *name, int *removed, \ | |||
247 | 248 | ||
248 | if (del == 0) | 249 | if (del == 0) |
249 | { | 250 | { |
250 | if ((system == TIDY_WIN) || (system == TIDY_BOTH)) | 251 | if ((system == TIDY_WIN) || (system == TIDY_ALL)) |
251 | { | 252 | { |
252 | /* windows directories */ | 253 | /* windows directories */ |
253 | if (rb->strcmp(entry->d_name, "Recycled") == 0 \ | 254 | if (rb->strcmp(entry->d_name, "Recycled") == 0 \ |
@@ -273,7 +274,7 @@ enum tidy_return tidy_clean(const char *name, int *removed, \ | |||
273 | /* file */ | 274 | /* file */ |
274 | del = 0; | 275 | del = 0; |
275 | 276 | ||
276 | if ((system == TIDY_MAC) || (system == TIDY_BOTH)) | 277 | if ((system == TIDY_MAC) || (system == TIDY_ALL)) |
277 | { | 278 | { |
278 | /* remove mac files */ | 279 | /* remove mac files */ |
279 | if ((rb->strcmp(entry->d_name, ".DS_Store") == 0) || \ | 280 | if ((rb->strcmp(entry->d_name, ".DS_Store") == 0) || \ |
@@ -293,7 +294,7 @@ enum tidy_return tidy_clean(const char *name, int *removed, \ | |||
293 | 294 | ||
294 | if (del == 0) | 295 | if (del == 0) |
295 | { | 296 | { |
296 | if ((system == TIDY_WIN) || (system == TIDY_BOTH)) | 297 | if ((system == TIDY_WIN) || (system == TIDY_ALL)) |
297 | { | 298 | { |
298 | /* remove windows files*/ | 299 | /* remove windows files*/ |
299 | if ((rb->strcmp(entry->d_name, "Thumbs.db") == 0)) | 300 | if ((rb->strcmp(entry->d_name, "Thumbs.db") == 0)) |
@@ -308,9 +309,29 @@ enum tidy_return tidy_clean(const char *name, int *removed, \ | |||
308 | rb->remove(fullname); | 309 | rb->remove(fullname); |
309 | del = 1; | 310 | del = 1; |
310 | } | 311 | } |
311 | } | 312 | } |
313 | } | ||
314 | if (del == 0) | ||
315 | { | ||
316 | if ((system ==TIDY_NIX) || (system == TIDY_ALL)) | ||
317 | { | ||
318 | /* remove linux files*/ | ||
319 | if ((rb->strcmp(entry->d_name, ".dolphinview") == 0) || \ | ||
320 | (rb->strncmp(entry->d_name, ".d3lphinview", 2) == 0)) | ||
321 | { | ||
322 | *removed += 1; /* increment removed files counter */ | ||
323 | |||
324 | /* get absolute path */ | ||
325 | char fullname[MAX_PATH]; | ||
326 | tidy_get_absolute_path(entry, fullname, name); | ||
327 | |||
328 | /* delete file */ | ||
329 | rb->remove(fullname); | ||
330 | del = 1; | ||
331 | } | ||
332 | } | ||
312 | } | 333 | } |
313 | } | 334 | } |
314 | } | 335 | } |
315 | rb->closedir(dir); | 336 | rb->closedir(dir); |
316 | return status; | 337 | return status; |
@@ -354,17 +375,18 @@ enum plugin_status tidy_do(enum tidy_system system) | |||
354 | 375 | ||
355 | int tidy_lcd_menu(void) | 376 | int tidy_lcd_menu(void) |
356 | { | 377 | { |
357 | int selection, ret = 2; | 378 | int selection, ret = 3; |
358 | bool menu_quit = false; | 379 | bool menu_quit = false; |
359 | 380 | ||
360 | MENUITEM_STRINGLIST(menu,"Disktidy Menu",NULL,"Start Cleaning", | 381 | MENUITEM_STRINGLIST(menu,"Disktidy Menu",NULL,"Start Cleaning", |
361 | "Files to Clean","Quit"); | 382 | "Files to Clean","Quit"); |
362 | 383 | ||
363 | static const struct opt_items system_option[3] = | 384 | static const struct opt_items system_option[] = |
364 | { | 385 | { |
365 | { "Mac", -1 }, | 386 | { "Mac", -1 }, |
366 | { "Windows", -1 }, | 387 | { "Windows", -1 }, |
367 | { "Both", -1 } | 388 | { "Linux", -1 }, |
389 | { "All", -1 } | ||
368 | }; | 390 | }; |
369 | 391 | ||
370 | while (!menu_quit) | 392 | while (!menu_quit) |
@@ -377,7 +399,7 @@ int tidy_lcd_menu(void) | |||
377 | break; | 399 | break; |
378 | 400 | ||
379 | case 1: | 401 | case 1: |
380 | rb->set_option("Files to Clean", &ret, INT, system_option, 3, NULL); | 402 | rb->set_option("Files to Clean", &ret, INT, system_option, 4, NULL); |
381 | break; | 403 | break; |
382 | 404 | ||
383 | default: | 405 | default: |
@@ -392,7 +414,7 @@ int tidy_lcd_menu(void) | |||
392 | /* this is the plugin entry point */ | 414 | /* this is the plugin entry point */ |
393 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 415 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
394 | { | 416 | { |
395 | enum tidy_system system = TIDY_BOTH; | 417 | enum tidy_system system = TIDY_ALL; |
396 | enum tidy_return status; | 418 | enum tidy_return status; |
397 | 419 | ||
398 | (void)parameter; | 420 | (void)parameter; |
@@ -408,12 +430,15 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
408 | system = TIDY_WIN; | 430 | system = TIDY_WIN; |
409 | break; | 431 | break; |
410 | case 2: | 432 | case 2: |
411 | system = TIDY_BOTH; | 433 | system = TIDY_NIX; |
434 | break; | ||
435 | case 3: | ||
436 | system = TIDY_ALL; | ||
412 | break; | 437 | break; |
413 | case 99: | 438 | case 99: |
414 | return PLUGIN_OK; | 439 | return PLUGIN_OK; |
415 | default: | 440 | default: |
416 | system = TIDY_BOTH; | 441 | system = TIDY_ALL; |
417 | } | 442 | } |
418 | 443 | ||
419 | while (true) | 444 | while (true) |