diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/disktidy.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c index cc883fea9c..c5f0f4a7bd 100644 --- a/apps/plugins/disktidy.c +++ b/apps/plugins/disktidy.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "errno.h" | 22 | #include "errno.h" |
23 | 23 | ||
24 | 24 | ||
25 | static int removed = 0; /* number of items removed */ | ||
25 | 26 | ||
26 | /* function return values */ | 27 | /* function return values */ |
27 | enum tidy_return | 28 | enum tidy_return |
@@ -158,14 +159,14 @@ bool tidy_remove_item(char *item, int attr) | |||
158 | return ret; | 159 | return ret; |
159 | } | 160 | } |
160 | 161 | ||
161 | void tidy_lcd_status(const char *name, int *removed) | 162 | void tidy_lcd_status(const char *name) |
162 | { | 163 | { |
163 | /* display status text */ | 164 | /* display status text */ |
164 | rb->lcd_clear_display(); | 165 | rb->lcd_clear_display(); |
165 | rb->lcd_puts(0, 0, "Working ..."); | 166 | rb->lcd_puts(0, 0, "Working ..."); |
166 | rb->lcd_puts(0, 1, name); | 167 | rb->lcd_puts(0, 1, name); |
167 | #ifdef HAVE_LCD_BITMAP | 168 | #ifdef HAVE_LCD_BITMAP |
168 | rb->lcd_putsf(0, 2, "Cleaned up %d items", *removed); | 169 | rb->lcd_putsf(0, 2, "Cleaned up %d items", removed); |
169 | #endif | 170 | #endif |
170 | rb->lcd_update(); | 171 | rb->lcd_update(); |
171 | } | 172 | } |
@@ -202,7 +203,7 @@ void tidy_path_remove_entry(char *path, int old_path_length, int *path_length) | |||
202 | } | 203 | } |
203 | 204 | ||
204 | /* path is assumed to be array of size MAX_PATH */ | 205 | /* path is assumed to be array of size MAX_PATH */ |
205 | enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) | 206 | enum tidy_return tidy_removedir(char *path, int *path_length) |
206 | { | 207 | { |
207 | /* delete directory */ | 208 | /* delete directory */ |
208 | struct dirent *entry; | 209 | struct dirent *entry; |
@@ -212,7 +213,7 @@ enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) | |||
212 | int old_path_length = *path_length; | 213 | int old_path_length = *path_length; |
213 | 214 | ||
214 | /* display status text */ | 215 | /* display status text */ |
215 | tidy_lcd_status(path, removed); | 216 | tidy_lcd_status(path); |
216 | 217 | ||
217 | rb->yield(); | 218 | rb->yield(); |
218 | 219 | ||
@@ -249,13 +250,13 @@ enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) | |||
249 | if ((rb->strcmp(entry->d_name, ".") != 0) && \ | 250 | if ((rb->strcmp(entry->d_name, ".") != 0) && \ |
250 | (rb->strcmp(entry->d_name, "..") != 0)) | 251 | (rb->strcmp(entry->d_name, "..") != 0)) |
251 | { | 252 | { |
252 | tidy_removedir(path, path_length, removed); | 253 | tidy_removedir(path, path_length); |
253 | } | 254 | } |
254 | } | 255 | } |
255 | else | 256 | else |
256 | { | 257 | { |
257 | /* file */ | 258 | /* file */ |
258 | *removed += 1; | 259 | removed++; |
259 | rb->remove(path); | 260 | rb->remove(path); |
260 | } | 261 | } |
261 | 262 | ||
@@ -264,7 +265,7 @@ enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) | |||
264 | } | 265 | } |
265 | rb->closedir(dir); | 266 | rb->closedir(dir); |
266 | /* rmdir */ | 267 | /* rmdir */ |
267 | *removed += 1; | 268 | removed++; |
268 | rb->rmdir(path); | 269 | rb->rmdir(path); |
269 | } | 270 | } |
270 | else | 271 | else |
@@ -275,7 +276,7 @@ enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) | |||
275 | } | 276 | } |
276 | 277 | ||
277 | /* path is assumed to be array of size MAX_PATH */ | 278 | /* path is assumed to be array of size MAX_PATH */ |
278 | enum tidy_return tidy_clean(char *path, int *path_length, int *removed) | 279 | enum tidy_return tidy_clean(char *path, int *path_length) |
279 | { | 280 | { |
280 | /* deletes junk files and dirs left by system */ | 281 | /* deletes junk files and dirs left by system */ |
281 | struct dirent *entry; | 282 | struct dirent *entry; |
@@ -286,7 +287,7 @@ enum tidy_return tidy_clean(char *path, int *path_length, int *removed) | |||
286 | int old_path_length = *path_length; | 287 | int old_path_length = *path_length; |
287 | 288 | ||
288 | /* display status text */ | 289 | /* display status text */ |
289 | tidy_lcd_status(path, removed); | 290 | tidy_lcd_status(path); |
290 | 291 | ||
291 | rb->yield(); | 292 | rb->yield(); |
292 | 293 | ||
@@ -328,14 +329,14 @@ enum tidy_return tidy_clean(char *path, int *path_length, int *removed) | |||
328 | if (tidy_remove_item(entry->d_name, entry->attribute)) | 329 | if (tidy_remove_item(entry->d_name, entry->attribute)) |
329 | { | 330 | { |
330 | /* delete dir */ | 331 | /* delete dir */ |
331 | tidy_removedir(path, path_length, removed); | 332 | tidy_removedir(path, path_length); |
332 | del = 1; | 333 | del = 1; |
333 | } | 334 | } |
334 | 335 | ||
335 | if (del == 0) | 336 | if (del == 0) |
336 | { | 337 | { |
337 | /* dir not deleted so clean it */ | 338 | /* dir not deleted so clean it */ |
338 | status = tidy_clean(path, path_length, removed); | 339 | status = tidy_clean(path, path_length); |
339 | } | 340 | } |
340 | 341 | ||
341 | /* restore path */ | 342 | /* restore path */ |
@@ -354,7 +355,7 @@ enum tidy_return tidy_clean(char *path, int *path_length, int *removed) | |||
354 | /* silent error */ | 355 | /* silent error */ |
355 | continue; | 356 | continue; |
356 | 357 | ||
357 | *removed += 1; /* increment removed files counter */ | 358 | removed++; /* increment removed files counter */ |
358 | /* delete file */ | 359 | /* delete file */ |
359 | rb->remove(path); | 360 | rb->remove(path); |
360 | del = 1; | 361 | del = 1; |
@@ -376,9 +377,7 @@ enum tidy_return tidy_clean(char *path, int *path_length, int *removed) | |||
376 | enum tidy_return tidy_do(void) | 377 | enum tidy_return tidy_do(void) |
377 | { | 378 | { |
378 | /* clean disk and display num of items removed */ | 379 | /* clean disk and display num of items removed */ |
379 | int removed = 0; | ||
380 | enum tidy_return status; | 380 | enum tidy_return status; |
381 | char text[24]; /* "Cleaned up nnnnn items" */ | ||
382 | char path[MAX_PATH]; | 381 | char path[MAX_PATH]; |
383 | int path_length; | 382 | int path_length; |
384 | 383 | ||
@@ -388,7 +387,7 @@ enum tidy_return tidy_do(void) | |||
388 | 387 | ||
389 | rb->strcpy(path, "/"); | 388 | rb->strcpy(path, "/"); |
390 | path_length = rb->strlen(path); | 389 | path_length = rb->strlen(path); |
391 | status = tidy_clean(path, &path_length, &removed); | 390 | status = tidy_clean(path, &path_length); |
392 | 391 | ||
393 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 392 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
394 | rb->cpu_boost(false); | 393 | rb->cpu_boost(false); |
@@ -397,13 +396,12 @@ enum tidy_return tidy_do(void) | |||
397 | if ((status == TIDY_RETURN_OK) || (status == TIDY_RETURN_ABORT)) | 396 | if ((status == TIDY_RETURN_OK) || (status == TIDY_RETURN_ABORT)) |
398 | { | 397 | { |
399 | rb->lcd_clear_display(); | 398 | rb->lcd_clear_display(); |
400 | rb->snprintf(text, 24, "Cleaned up %d items", removed); | ||
401 | if (status == TIDY_RETURN_ABORT) | 399 | if (status == TIDY_RETURN_ABORT) |
402 | { | 400 | { |
403 | rb->splash(HZ, "User aborted"); | 401 | rb->splash(HZ, "User aborted"); |
404 | rb->lcd_clear_display(); | 402 | rb->lcd_clear_display(); |
405 | } | 403 | } |
406 | rb->splash(HZ*2, text); | 404 | rb->splashf(HZ*2, "Cleaned up %d items", removed); |
407 | } | 405 | } |
408 | return status; | 406 | return status; |
409 | } | 407 | } |