summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-07-31 12:57:22 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-07-31 12:57:22 +0000
commitc687f8c687a203e578611f66108f09e641f8092b (patch)
treea1aa4ac7a155e4cbbae4b1441c352b6d717f0d7d
parent60b01fa0f7e5126406d1fd2f37cce82d2faffdc4 (diff)
downloadrockbox-c687f8c687a203e578611f66108f09e641f8092b.tar.gz
rockbox-c687f8c687a203e578611f66108f09e641f8092b.zip
FS#2735 - stats plugin now shows the number of files in the biggest directory
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14101 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/stats.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index dca5e89753..a33331a429 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -21,7 +21,7 @@
21PLUGIN_HEADER 21PLUGIN_HEADER
22 22
23static struct plugin_api* rb; 23static struct plugin_api* rb;
24static int files, dirs, musicfiles; 24static int files, dirs, musicfiles, largestdir;
25static int lasttick; 25static int lasttick;
26static bool abort; 26static bool abort;
27 27
@@ -76,7 +76,7 @@ void prn(const char *str, int y)
76 76
77void update_screen(void) 77void update_screen(void)
78{ 78{
79 char buf[15]; 79 char buf[32];
80 80
81 rb->lcd_clear_display(); 81 rb->lcd_clear_display();
82#ifdef HAVE_REMOTE_LCD 82#ifdef HAVE_REMOTE_LCD
@@ -90,6 +90,8 @@ void update_screen(void)
90 prn(buf,1); 90 prn(buf,1);
91 rb->snprintf(buf, sizeof(buf), "Dirs: %d", dirs); 91 rb->snprintf(buf, sizeof(buf), "Dirs: %d", dirs);
92 prn(buf,2); 92 prn(buf,2);
93 rb->snprintf(buf, sizeof(buf), "Max files in Dir: %d", largestdir);
94 prn(buf,3);
93#else 95#else
94 rb->snprintf(buf, sizeof(buf), "Files:%5d", files); 96 rb->snprintf(buf, sizeof(buf), "Files:%5d", files);
95 prn(buf,0); 97 prn(buf,0);
@@ -109,6 +111,7 @@ void traversedir(char* location, char* name)
109 struct dirent *entry; 111 struct dirent *entry;
110 DIR* dir; 112 DIR* dir;
111 char fullpath[MAX_PATH]; 113 char fullpath[MAX_PATH];
114 int files_in_dir = 0;
112 115
113 rb->snprintf(fullpath, sizeof(fullpath), "%s/%s", location, name); 116 rb->snprintf(fullpath, sizeof(fullpath), "%s/%s", location, name);
114 dir = rb->opendir(fullpath); 117 dir = rb->opendir(fullpath);
@@ -126,7 +129,7 @@ void traversedir(char* location, char* name)
126 } 129 }
127 else { 130 else {
128 char *ptr = rb->strrchr(entry->d_name,'.'); 131 char *ptr = rb->strrchr(entry->d_name,'.');
129 files++; 132 files++; files_in_dir++;
130 /* Might want to only count .mp3, .ogg etc. */ 133 /* Might want to only count .mp3, .ogg etc. */
131 if(ptr){ 134 if(ptr){
132 unsigned i; 135 unsigned i;
@@ -157,6 +160,8 @@ void traversedir(char* location, char* name)
157 } 160 }
158 rb->closedir(dir); 161 rb->closedir(dir);
159 } 162 }
163 if (largestdir < files_in_dir)
164 largestdir = files_in_dir;
160} 165}
161 166
162enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 167enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
@@ -169,6 +174,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
169 files = 0; 174 files = 0;
170 dirs = 0; 175 dirs = 0;
171 musicfiles = 0; 176 musicfiles = 0;
177 largestdir = 0;
172 abort = false; 178 abort = false;
173 179
174 rb->splash(HZ, "Counting..."); 180 rb->splash(HZ, "Counting...");