diff options
| author | Rafaël Carré <rafael.carre@gmail.com> | 2010-08-28 22:01:44 +0000 |
|---|---|---|
| committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-08-28 22:01:44 +0000 |
| commit | e02e1db528088889e24d11eff67d38b71eb4fbc6 (patch) | |
| tree | 28152d0598fe0fc2fe9753dba41599a40f0cc60d /apps/plugins | |
| parent | 502997c0428224e64a7455b47b3d757cdf225939 (diff) | |
| download | rockbox-e02e1db528088889e24d11eff67d38b71eb4fbc6.zip rockbox-e02e1db528088889e24d11eff67d38b71eb4fbc6.tar.gz rockbox-e02e1db528088889e24d11eff67d38b71eb4fbc6.tar.bz2 rockbox-e02e1db528088889e24d11eff67d38b71eb4fbc6.tar.xz | |
disktidy: store the number of removed files as global scope
no need to transmit it through function arguments, remove a warning on
charcell as a side effect
also, snprintf+splash -> splashf
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27930 a1c6a512-1295-4272-9138-f99709370657
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 cc883fe..c5f0f4a 100644 --- a/apps/plugins/disktidy.c +++ b/apps/plugins/disktidy.c @@ -22,6 +22,7 @@ #include "errno.h" +static int removed = 0; /* number of items removed */ /* function return values */ enum tidy_return @@ -158,14 +159,14 @@ bool tidy_remove_item(char *item, int attr) return ret; } -void tidy_lcd_status(const char *name, int *removed) +void tidy_lcd_status(const char *name) { /* display status text */ rb->lcd_clear_display(); rb->lcd_puts(0, 0, "Working ..."); rb->lcd_puts(0, 1, name); #ifdef HAVE_LCD_BITMAP - rb->lcd_putsf(0, 2, "Cleaned up %d items", *removed); + rb->lcd_putsf(0, 2, "Cleaned up %d items", removed); #endif rb->lcd_update(); } @@ -202,7 +203,7 @@ void tidy_path_remove_entry(char *path, int old_path_length, int *path_length) } /* path is assumed to be array of size MAX_PATH */ -enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) +enum tidy_return tidy_removedir(char *path, int *path_length) { /* delete directory */ struct dirent *entry; @@ -212,7 +213,7 @@ enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) int old_path_length = *path_length; /* display status text */ - tidy_lcd_status(path, removed); + tidy_lcd_status(path); rb->yield(); @@ -249,13 +250,13 @@ enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) if ((rb->strcmp(entry->d_name, ".") != 0) && \ (rb->strcmp(entry->d_name, "..") != 0)) { - tidy_removedir(path, path_length, removed); + tidy_removedir(path, path_length); } } else { /* file */ - *removed += 1; + removed++; rb->remove(path); } @@ -264,7 +265,7 @@ enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) } rb->closedir(dir); /* rmdir */ - *removed += 1; + removed++; rb->rmdir(path); } else @@ -275,7 +276,7 @@ enum tidy_return tidy_removedir(char *path, int *path_length, int *removed) } /* path is assumed to be array of size MAX_PATH */ -enum tidy_return tidy_clean(char *path, int *path_length, int *removed) +enum tidy_return tidy_clean(char *path, int *path_length) { /* deletes junk files and dirs left by system */ struct dirent *entry; @@ -286,7 +287,7 @@ enum tidy_return tidy_clean(char *path, int *path_length, int *removed) int old_path_length = *path_length; /* display status text */ - tidy_lcd_status(path, removed); + tidy_lcd_status(path); rb->yield(); @@ -328,14 +329,14 @@ enum tidy_return tidy_clean(char *path, int *path_length, int *removed) if (tidy_remove_item(entry->d_name, entry->attribute)) { /* delete dir */ - tidy_removedir(path, path_length, removed); + tidy_removedir(path, path_length); del = 1; } if (del == 0) { /* dir not deleted so clean it */ - status = tidy_clean(path, path_length, removed); + status = tidy_clean(path, path_length); } /* restore path */ @@ -354,7 +355,7 @@ enum tidy_return tidy_clean(char *path, int *path_length, int *removed) /* silent error */ continue; - *removed += 1; /* increment removed files counter */ + removed++; /* increment removed files counter */ /* delete file */ rb->remove(path); del = 1; @@ -376,9 +377,7 @@ enum tidy_return tidy_clean(char *path, int *path_length, int *removed) enum tidy_return tidy_do(void) { /* clean disk and display num of items removed */ - int removed = 0; enum tidy_return status; - char text[24]; /* "Cleaned up nnnnn items" */ char path[MAX_PATH]; int path_length; @@ -388,7 +387,7 @@ enum tidy_return tidy_do(void) rb->strcpy(path, "/"); path_length = rb->strlen(path); - status = tidy_clean(path, &path_length, &removed); + status = tidy_clean(path, &path_length); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); @@ -397,13 +396,12 @@ enum tidy_return tidy_do(void) if ((status == TIDY_RETURN_OK) || (status == TIDY_RETURN_ABORT)) { rb->lcd_clear_display(); - rb->snprintf(text, 24, "Cleaned up %d items", removed); if (status == TIDY_RETURN_ABORT) { rb->splash(HZ, "User aborted"); rb->lcd_clear_display(); } - rb->splash(HZ*2, text); + rb->splashf(HZ*2, "Cleaned up %d items", removed); } return status; } |