diff options
author | Mustapha Senhaji <moos@rockbox.org> | 2010-12-28 14:42:30 +0000 |
---|---|---|
committer | Mustapha Senhaji <moos@rockbox.org> | 2010-12-28 14:42:30 +0000 |
commit | afd855b598f5660eb9b420e65af57ef28346c1f9 (patch) | |
tree | 03ebaeb6b7bf7a38527d6f47a27d77561e07c8bb /apps/plugins | |
parent | c53069c41c9d96ad004b18fe6a1526b36473d07c (diff) | |
download | rockbox-afd855b598f5660eb9b420e65af57ef28346c1f9.tar.gz rockbox-afd855b598f5660eb9b420e65af57ef28346c1f9.zip |
stats plugin: Add new things to count. Playlist and video files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28921 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/stats.c | 71 |
1 files changed, 60 insertions, 11 deletions
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c index 11962043c4..07f2f8efb8 100644 --- a/apps/plugins/stats.c +++ b/apps/plugins/stats.c | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | 23 | ||
24 | 24 | ||
25 | static int files, dirs, musicfiles, largestdir; | 25 | static int files, dirs, audiofiles, m3ufiles, imagefiles, videofiles, largestdir; |
26 | static int lasttick; | 26 | static int lasttick; |
27 | static bool cancel; | 27 | static bool cancel; |
28 | 28 | ||
@@ -114,6 +114,12 @@ static bool cancel; | |||
114 | #error No keymap defined! | 114 | #error No keymap defined! |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | /* we don't have yet a filetype attribute for image files */ | ||
118 | const char *image_exts[] = {"bmp","jpg","jpe","jpeg","png","ppm"}; | ||
119 | |||
120 | /* neither for video ones */ | ||
121 | const char *video_exts[] = {"mpg","mpeg","mpv","m2v"}; | ||
122 | |||
117 | void prn(const char *str, int y) | 123 | void prn(const char *str, int y) |
118 | { | 124 | { |
119 | rb->lcd_puts(0,y,str); | 125 | rb->lcd_puts(0,y,str); |
@@ -132,14 +138,20 @@ void update_screen(void) | |||
132 | #endif | 138 | #endif |
133 | 139 | ||
134 | #ifdef HAVE_LCD_BITMAP | 140 | #ifdef HAVE_LCD_BITMAP |
135 | rb->snprintf(buf, sizeof(buf), "Files: %d", files); | 141 | rb->snprintf(buf, sizeof(buf), "Total Files: %d", files); |
136 | prn(buf,0); | 142 | prn(buf,0); |
137 | rb->snprintf(buf, sizeof(buf), "Music: %d", musicfiles); | 143 | rb->snprintf(buf, sizeof(buf), "Audio: %d", audiofiles); |
138 | prn(buf,1); | 144 | prn(buf,1); |
139 | rb->snprintf(buf, sizeof(buf), "Dirs: %d", dirs); | 145 | rb->snprintf(buf, sizeof(buf), "Playlists: %d", m3ufiles); |
140 | prn(buf,2); | 146 | prn(buf,2); |
141 | rb->snprintf(buf, sizeof(buf), "Max files in Dir: %d", largestdir); | 147 | rb->snprintf(buf, sizeof(buf), "Images: %d", imagefiles); |
142 | prn(buf,3); | 148 | prn(buf,3); |
149 | rb->snprintf(buf, sizeof(buf), "Videos: %d", videofiles); | ||
150 | prn(buf,4); | ||
151 | rb->snprintf(buf, sizeof(buf), "Directories: %d", dirs); | ||
152 | prn(buf,5); | ||
153 | rb->snprintf(buf, sizeof(buf), "Max files in Dir: %d", largestdir); | ||
154 | prn(buf,6); | ||
143 | #else | 155 | #else |
144 | rb->snprintf(buf, sizeof(buf), "Files:%5d", files); | 156 | rb->snprintf(buf, sizeof(buf), "Files:%5d", files); |
145 | prn(buf,0); | 157 | prn(buf,0); |
@@ -177,15 +189,49 @@ void traversedir(char* location, char* name) | |||
177 | dirs++; | 189 | dirs++; |
178 | } | 190 | } |
179 | else { | 191 | else { |
192 | files_in_dir++; files++; | ||
193 | |||
194 | /* get the filetype from the filename */ | ||
180 | int attr = rb->filetype_get_attr(entry->d_name); | 195 | int attr = rb->filetype_get_attr(entry->d_name); |
181 | if ((attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) | 196 | switch (attr & FILE_ATTR_MASK) |
197 | { | ||
198 | case FILE_ATTR_AUDIO: | ||
199 | audiofiles++; | ||
200 | break; | ||
201 | |||
202 | case FILE_ATTR_M3U: | ||
203 | m3ufiles++; | ||
204 | break; | ||
205 | |||
206 | default: | ||
182 | { | 207 | { |
183 | musicfiles++; | 208 | /* use hardcoded filetype_exts to count |
184 | } | 209 | * image and video files until we get |
185 | files++; files_in_dir++; | 210 | * new attributes added to filetypes.h */ |
186 | } | 211 | char *ptr = rb->strrchr(entry->d_name,'.'); |
212 | if(ptr) { | ||
213 | unsigned i; | ||
214 | ptr++; | ||
215 | for(i=0;i<ARRAYLEN(image_exts);i++) { | ||
216 | if(!rb->strcasecmp(ptr,image_exts[i])) { | ||
217 | imagefiles++; break; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | if (i >= ARRAYLEN(image_exts)) { | ||
222 | /* not found above - try video files */ | ||
223 | for(i=0;i<ARRAYLEN(video_exts);i++) { | ||
224 | if(!rb->strcasecmp(ptr,video_exts[i])) { | ||
225 | videofiles++; break; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | } /* default: */ | ||
231 | } /* switch */ | ||
187 | } | 232 | } |
188 | } | 233 | } |
234 | |||
189 | if (*rb->current_tick - lasttick > (HZ/2)) { | 235 | if (*rb->current_tick - lasttick > (HZ/2)) { |
190 | update_screen(); | 236 | update_screen(); |
191 | lasttick = *rb->current_tick; | 237 | lasttick = *rb->current_tick; |
@@ -217,7 +263,10 @@ enum plugin_status plugin_start(const void* parameter) | |||
217 | 263 | ||
218 | files = 0; | 264 | files = 0; |
219 | dirs = 0; | 265 | dirs = 0; |
220 | musicfiles = 0; | 266 | audiofiles = 0; |
267 | m3ufiles = 0; | ||
268 | imagefiles = 0; | ||
269 | videofiles = 0; | ||
221 | largestdir = 0; | 270 | largestdir = 0; |
222 | cancel = false; | 271 | cancel = false; |
223 | 272 | ||