diff options
Diffstat (limited to 'apps/plugins/disktidy.c')
-rw-r--r-- | apps/plugins/disktidy.c | 89 |
1 files changed, 45 insertions, 44 deletions
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c index 53af3a2f95..b7b9aa1770 100644 --- a/apps/plugins/disktidy.c +++ b/apps/plugins/disktidy.c | |||
@@ -141,7 +141,7 @@ bool tidy_remove_item(char *item, int attr) | |||
141 | if (file[rb->strlen(file)-1] == '*') | 141 | if (file[rb->strlen(file)-1] == '*') |
142 | { | 142 | { |
143 | if (!rb->strncmp(file, item, rb->strlen(file)-1)) | 143 | if (!rb->strncmp(file, item, rb->strlen(file)-1)) |
144 | rem = true; | 144 | rem = true; |
145 | } | 145 | } |
146 | else if (!rb->strcmp(file, item)) | 146 | else if (!rb->strcmp(file, item)) |
147 | rem = true; | 147 | rem = true; |
@@ -192,12 +192,12 @@ enum tidy_return tidy_removedir(const char *name, int *removed) | |||
192 | int button; | 192 | int button; |
193 | DIR *dir; | 193 | DIR *dir; |
194 | char fullname[MAX_PATH]; | 194 | char fullname[MAX_PATH]; |
195 | 195 | ||
196 | /* display status text */ | 196 | /* display status text */ |
197 | tidy_lcd_status(name, removed); | 197 | tidy_lcd_status(name, removed); |
198 | 198 | ||
199 | rb->yield(); | 199 | rb->yield(); |
200 | 200 | ||
201 | dir = rb->opendir(name); | 201 | dir = rb->opendir(name); |
202 | if (dir) | 202 | if (dir) |
203 | { | 203 | { |
@@ -216,12 +216,12 @@ enum tidy_return tidy_removedir(const char *name, int *removed) | |||
216 | rb->closedir(dir); | 216 | rb->closedir(dir); |
217 | return TIDY_RETURN_USB; | 217 | return TIDY_RETURN_USB; |
218 | } | 218 | } |
219 | 219 | ||
220 | rb->yield(); | 220 | rb->yield(); |
221 | 221 | ||
222 | /* get absolute path */ | 222 | /* get absolute path */ |
223 | tidy_get_absolute_path(entry, fullname, name); | 223 | tidy_get_absolute_path(entry, fullname, name); |
224 | 224 | ||
225 | if (entry->attribute & ATTR_DIRECTORY) | 225 | if (entry->attribute & ATTR_DIRECTORY) |
226 | { | 226 | { |
227 | /* dir ignore "." and ".." */ | 227 | /* dir ignore "." and ".." */ |
@@ -259,12 +259,12 @@ enum tidy_return tidy_clean(const char *name, int *removed) | |||
259 | int del; /* has the item been deleted */ | 259 | int del; /* has the item been deleted */ |
260 | DIR *dir; | 260 | DIR *dir; |
261 | char fullname[MAX_PATH]; | 261 | char fullname[MAX_PATH]; |
262 | 262 | ||
263 | /* display status text */ | 263 | /* display status text */ |
264 | tidy_lcd_status(name, removed); | 264 | tidy_lcd_status(name, removed); |
265 | 265 | ||
266 | rb->yield(); | 266 | rb->yield(); |
267 | 267 | ||
268 | dir = rb->opendir(name); | 268 | dir = rb->opendir(name); |
269 | if (dir) | 269 | if (dir) |
270 | { | 270 | { |
@@ -283,9 +283,9 @@ enum tidy_return tidy_clean(const char *name, int *removed) | |||
283 | rb->closedir(dir); | 283 | rb->closedir(dir); |
284 | return TIDY_RETURN_USB; | 284 | return TIDY_RETURN_USB; |
285 | } | 285 | } |
286 | 286 | ||
287 | rb->yield(); | 287 | rb->yield(); |
288 | 288 | ||
289 | if (entry->attribute & ATTR_DIRECTORY) | 289 | if (entry->attribute & ATTR_DIRECTORY) |
290 | { | 290 | { |
291 | /* directory ignore "." and ".." */ | 291 | /* directory ignore "." and ".." */ |
@@ -293,17 +293,17 @@ enum tidy_return tidy_clean(const char *name, int *removed) | |||
293 | (rb->strcmp(entry->d_name, "..") != 0)) | 293 | (rb->strcmp(entry->d_name, "..") != 0)) |
294 | { | 294 | { |
295 | del = 0; | 295 | del = 0; |
296 | 296 | ||
297 | /* get absolute path */ | 297 | /* get absolute path */ |
298 | tidy_get_absolute_path(entry, fullname, name); | 298 | tidy_get_absolute_path(entry, fullname, name); |
299 | 299 | ||
300 | if (tidy_remove_item(entry->d_name, entry->attribute)) | 300 | if (tidy_remove_item(entry->d_name, entry->attribute)) |
301 | { | 301 | { |
302 | /* delete dir */ | 302 | /* delete dir */ |
303 | tidy_removedir(fullname, removed); | 303 | tidy_removedir(fullname, removed); |
304 | del = 1; | 304 | del = 1; |
305 | } | 305 | } |
306 | 306 | ||
307 | if (del == 0) | 307 | if (del == 0) |
308 | { | 308 | { |
309 | /* dir not deleted so clean it */ | 309 | /* dir not deleted so clean it */ |
@@ -318,11 +318,11 @@ enum tidy_return tidy_clean(const char *name, int *removed) | |||
318 | if (tidy_remove_item(entry->d_name, entry->attribute)) | 318 | if (tidy_remove_item(entry->d_name, entry->attribute)) |
319 | { | 319 | { |
320 | *removed += 1; /* increment removed files counter */ | 320 | *removed += 1; /* increment removed files counter */ |
321 | 321 | ||
322 | /* get absolute path */ | 322 | /* get absolute path */ |
323 | char fullname[MAX_PATH]; | 323 | char fullname[MAX_PATH]; |
324 | tidy_get_absolute_path(entry, fullname, name); | 324 | tidy_get_absolute_path(entry, fullname, name); |
325 | 325 | ||
326 | /* delete file */ | 326 | /* delete file */ |
327 | rb->remove(fullname); | 327 | rb->remove(fullname); |
328 | del = 1; | 328 | del = 1; |
@@ -338,23 +338,23 @@ enum tidy_return tidy_clean(const char *name, int *removed) | |||
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | enum plugin_status tidy_do(void) | 341 | enum tidy_return tidy_do(void) |
342 | { | 342 | { |
343 | /* clean disk and display num of items removed */ | 343 | /* clean disk and display num of items removed */ |
344 | int removed = 0; | 344 | int removed = 0; |
345 | enum tidy_return status; | 345 | enum tidy_return status; |
346 | char text[24]; /* "Cleaned up nnnnn items" */ | 346 | char text[24]; /* "Cleaned up nnnnn items" */ |
347 | 347 | ||
348 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 348 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
349 | rb->cpu_boost(true); | 349 | rb->cpu_boost(true); |
350 | #endif | 350 | #endif |
351 | 351 | ||
352 | status = tidy_clean("/", &removed); | 352 | status = tidy_clean("/", &removed); |
353 | 353 | ||
354 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 354 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
355 | rb->cpu_boost(false); | 355 | rb->cpu_boost(false); |
356 | #endif | 356 | #endif |
357 | 357 | ||
358 | if ((status == TIDY_RETURN_OK) || (status == TIDY_RETURN_ABORT)) | 358 | if ((status == TIDY_RETURN_OK) || (status == TIDY_RETURN_ABORT)) |
359 | { | 359 | { |
360 | rb->lcd_clear_display(); | 360 | rb->lcd_clear_display(); |
@@ -436,29 +436,32 @@ int list_action_callback(int action, struct gui_synclist *lists) | |||
436 | return action; | 436 | return action; |
437 | } | 437 | } |
438 | 438 | ||
439 | int tidy_lcd_menu(void) | 439 | enum tidy_return tidy_lcd_menu(void) |
440 | { | 440 | { |
441 | int selection, ret = 3; | 441 | int selection = 0; |
442 | enum tidy_return status = TIDY_RETURN_OK; | ||
442 | bool menu_quit = false; | 443 | bool menu_quit = false; |
443 | 444 | ||
444 | MENUITEM_STRINGLIST(menu,"Disktidy Menu",NULL,"Start Cleaning", | 445 | MENUITEM_STRINGLIST(menu, "Disktidy Menu", NULL, |
445 | "Files to Clean","Quit"); | 446 | "Start Cleaning", "Files to Clean", |
446 | 447 | "Quit"); | |
448 | |||
447 | while (!menu_quit) | 449 | while (!menu_quit) |
448 | { | 450 | { |
449 | switch(rb->do_menu(&menu, &selection, NULL, false)) | 451 | switch(rb->do_menu(&menu, &selection, NULL, false)) |
450 | { | 452 | { |
451 | |||
452 | case 0: | 453 | case 0: |
453 | menu_quit = true; /* start cleaning */ | 454 | menu_quit = true; /* start cleaning */ |
454 | break; | 455 | break; |
455 | 456 | ||
456 | case 1: | 457 | case 1: |
457 | { | 458 | { |
458 | bool show_icons = rb->global_settings->show_icons; | 459 | bool show_icons = rb->global_settings->show_icons; |
459 | struct simplelist_info list; | 460 | struct simplelist_info list; |
460 | rb->global_settings->show_icons = true; /* force the icons so its readable */ | 461 | /* force the icons so its readable */ |
461 | rb->simplelist_info_init(&list, "Files to Clean", tidy_type_count, NULL); | 462 | rb->global_settings->show_icons = true; |
463 | rb->simplelist_info_init(&list, "Files to Clean", | ||
464 | tidy_type_count, NULL); | ||
462 | list.get_icon = get_icon; | 465 | list.get_icon = get_icon; |
463 | list.get_name = get_name; | 466 | list.get_name = get_name; |
464 | list.action_callback = list_action_callback; | 467 | list.action_callback = list_action_callback; |
@@ -466,21 +469,20 @@ int tidy_lcd_menu(void) | |||
466 | rb->global_settings->show_icons = show_icons; | 469 | rb->global_settings->show_icons = show_icons; |
467 | } | 470 | } |
468 | break; | 471 | break; |
469 | 472 | ||
470 | default: | 473 | default: |
471 | ret = 99; /* exit plugin */ | 474 | status = TIDY_RETURN_ABORT; /* exit plugin */ |
472 | menu_quit = true; | 475 | menu_quit = true; |
473 | break; | 476 | break; |
474 | } | 477 | } |
475 | } | 478 | } |
476 | return ret; | 479 | return status; |
477 | } | 480 | } |
478 | 481 | ||
479 | /* this is the plugin entry point */ | 482 | /* this is the plugin entry point */ |
480 | enum plugin_status plugin_start(const void* parameter) | 483 | enum plugin_status plugin_start(const void* parameter) |
481 | { | 484 | { |
482 | enum tidy_return status; | 485 | enum tidy_return status; |
483 | int ret; | ||
484 | (void)parameter; | 486 | (void)parameter; |
485 | 487 | ||
486 | tidy_type_count = 0; | 488 | tidy_type_count = 0; |
@@ -491,7 +493,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
491 | rb->splash(3*HZ, "Missing disktidy.config file"); | 493 | rb->splash(3*HZ, "Missing disktidy.config file"); |
492 | return PLUGIN_ERROR; | 494 | return PLUGIN_ERROR; |
493 | } | 495 | } |
494 | ret = tidy_lcd_menu(); | 496 | status = tidy_lcd_menu(); |
495 | if (tidy_loaded_and_changed) | 497 | if (tidy_loaded_and_changed) |
496 | { | 498 | { |
497 | int fd = rb->creat(CUSTOM_FILES); | 499 | int fd = rb->creat(CUSTOM_FILES); |
@@ -507,7 +509,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
507 | rb->close(fd); | 509 | rb->close(fd); |
508 | } | 510 | } |
509 | } | 511 | } |
510 | if (ret == 99) | 512 | if (status == TIDY_RETURN_ABORT) |
511 | return PLUGIN_OK; | 513 | return PLUGIN_OK; |
512 | while (true) | 514 | while (true) |
513 | { | 515 | { |
@@ -520,17 +522,16 @@ enum plugin_status plugin_start(const void* parameter) | |||
520 | case TIDY_RETURN_ERROR: | 522 | case TIDY_RETURN_ERROR: |
521 | return PLUGIN_ERROR; | 523 | return PLUGIN_ERROR; |
522 | case TIDY_RETURN_USB: | 524 | case TIDY_RETURN_USB: |
523 | return PLUGIN_USB_CONNECTED; | 525 | return PLUGIN_USB_CONNECTED; |
524 | case TIDY_RETURN_ABORT: | 526 | case TIDY_RETURN_ABORT: |
525 | return PLUGIN_OK; | 527 | return PLUGIN_OK; |
526 | } | 528 | } |
527 | } | 529 | } |
528 | 530 | ||
529 | if (rb->default_event_handler(rb->button_get(false)) == SYS_USB_CONNECTED) | 531 | if (rb->default_event_handler(rb->button_get(false)) == SYS_USB_CONNECTED) |
530 | return PLUGIN_USB_CONNECTED; | 532 | return PLUGIN_USB_CONNECTED; |
531 | 533 | ||
532 | rb->yield(); | 534 | rb->yield(); |
533 | 535 | ||
534 | |||
535 | return PLUGIN_OK; | 536 | return PLUGIN_OK; |
536 | } | 537 | } |