summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-09-01 21:29:34 +0000
committerThomas Martitz <kugel@rockbox.org>2010-09-01 21:29:34 +0000
commit6eaab4d00446c070c655f0e6c9a872532a776b6f (patch)
tree69610996dd0a6092459b14e164d4e48e03b1e5bb /apps/plugins
parent8e0a0babc57db3e9edc06f3e269fb47c27292ed5 (diff)
downloadrockbox-6eaab4d00446c070c655f0e6c9a872532a776b6f.tar.gz
rockbox-6eaab4d00446c070c655f0e6c9a872532a776b6f.zip
Ged rid of uisimulator/common/io.c for android builds.
Use host's functions for file i/o directly (open(), close() ,etc.), not the sim_* variants. Some dir functions need to be wrapped still because we need to cache the parents dir's path (host's dirent doesn't let us know). For the same reason (incompatibility) with host's dirent) detach some members from Rockbox' dirent struct and put it into an extra one, the values can be retrieved via the new dir_get_info(). Get rid of the sim_ prefix for sleep as well and change the signature to unix sleep(). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27968 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/disktidy.c11
-rw-r--r--apps/plugins/lua/luadir.c3
-rw-r--r--apps/plugins/md5sum.c4
-rw-r--r--apps/plugins/properties.c23
-rw-r--r--apps/plugins/random_folder_advance_config.c3
-rw-r--r--apps/plugins/stats.c3
-rw-r--r--apps/plugins/theme_remove.c3
7 files changed, 31 insertions, 19 deletions
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c
index c5f0f4a7bd..1e6c1536e2 100644
--- a/apps/plugins/disktidy.c
+++ b/apps/plugins/disktidy.c
@@ -244,7 +244,9 @@ enum tidy_return tidy_removedir(char *path, int *path_length)
244 /* silent error */ 244 /* silent error */
245 continue; 245 continue;
246 246
247 if (entry->attribute & ATTR_DIRECTORY) 247
248 struct dirinfo info = rb->dir_get_info(dir, entry);
249 if (info.attribute & ATTR_DIRECTORY)
248 { 250 {
249 /* dir ignore "." and ".." */ 251 /* dir ignore "." and ".." */
250 if ((rb->strcmp(entry->d_name, ".") != 0) && \ 252 if ((rb->strcmp(entry->d_name, ".") != 0) && \
@@ -297,6 +299,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
297 while((status == TIDY_RETURN_OK) && ((entry = rb->readdir(dir)) != 0)) 299 while((status == TIDY_RETURN_OK) && ((entry = rb->readdir(dir)) != 0))
298 /* walk directory */ 300 /* walk directory */
299 { 301 {
302 struct dirinfo info = rb->dir_get_info(dir, entry);
300 /* check for user input and usb connect */ 303 /* check for user input and usb connect */
301 button = rb->get_action(CONTEXT_STD, TIMEOUT_NOBLOCK); 304 button = rb->get_action(CONTEXT_STD, TIMEOUT_NOBLOCK);
302 if (button == ACTION_STD_CANCEL) 305 if (button == ACTION_STD_CANCEL)
@@ -312,7 +315,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
312 315
313 rb->yield(); 316 rb->yield();
314 317
315 if (entry->attribute & ATTR_DIRECTORY) 318 if (info.attribute & ATTR_DIRECTORY)
316 { 319 {
317 /* directory ignore "." and ".." */ 320 /* directory ignore "." and ".." */
318 if ((rb->strcmp(entry->d_name, ".") != 0) && \ 321 if ((rb->strcmp(entry->d_name, ".") != 0) && \
@@ -326,7 +329,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
326 /* silent error */ 329 /* silent error */
327 continue; 330 continue;
328 331
329 if (tidy_remove_item(entry->d_name, entry->attribute)) 332 if (tidy_remove_item(entry->d_name, info.attribute))
330 { 333 {
331 /* delete dir */ 334 /* delete dir */
332 tidy_removedir(path, path_length); 335 tidy_removedir(path, path_length);
@@ -347,7 +350,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
347 { 350 {
348 /* file */ 351 /* file */
349 del = 0; 352 del = 0;
350 if (tidy_remove_item(entry->d_name, entry->attribute)) 353 if (tidy_remove_item(entry->d_name, info.attribute))
351 { 354 {
352 /* get absolute path */ 355 /* get absolute path */
353 /* returns an error if path is too long */ 356 /* returns an error if path is too long */
diff --git a/apps/plugins/lua/luadir.c b/apps/plugins/lua/luadir.c
index 730c40ce22..c8c21d2c65 100644
--- a/apps/plugins/lua/luadir.c
+++ b/apps/plugins/lua/luadir.c
@@ -56,8 +56,9 @@ static int dir_iter (lua_State *L) {
56 luaL_argcheck (L, !d->closed, 1, "closed directory"); 56 luaL_argcheck (L, !d->closed, 1, "closed directory");
57 57
58 if ((entry = rb->readdir (d->dir)) != NULL) { 58 if ((entry = rb->readdir (d->dir)) != NULL) {
59 struct dirinfo info = rb->dir_get_info(d->dir, entry);
59 lua_pushstring (L, entry->d_name); 60 lua_pushstring (L, entry->d_name);
60 lua_pushboolean (L, entry->attribute & ATTR_DIRECTORY); 61 lua_pushboolean (L, info.attribute & ATTR_DIRECTORY);
61 return 2; 62 return 2;
62 } else { 63 } else {
63 /* no more entries => close directory */ 64 /* no more entries => close directory */
diff --git a/apps/plugins/md5sum.c b/apps/plugins/md5sum.c
index fe1c65efb0..c993018852 100644
--- a/apps/plugins/md5sum.c
+++ b/apps/plugins/md5sum.c
@@ -95,7 +95,9 @@ static void hash_dir( int out, const char *path )
95 char childpath[MAX_PATH]; 95 char childpath[MAX_PATH];
96 rb->snprintf( childpath, MAX_PATH, "%s/%s", 96 rb->snprintf( childpath, MAX_PATH, "%s/%s",
97 rb->strcmp( path, "/" ) ? path : "", entry->d_name ); 97 rb->strcmp( path, "/" ) ? path : "", entry->d_name );
98 if( entry->attribute & ATTR_DIRECTORY ) 98
99 struct dirinfo info = rb->dir_get_info(dir, entry);
100 if (info.attribute & ATTR_DIRECTORY)
99 { 101 {
100 if( rb->strcmp( entry->d_name, "." ) 102 if( rb->strcmp( entry->d_name, "." )
101 && rb->strcmp( entry->d_name, ".." ) ) 103 && rb->strcmp( entry->d_name, ".." ) )
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index d6692bc893..e127a2908e 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -69,22 +69,23 @@ static bool file_properties(char* selected_file)
69 { 69 {
70 while(0 != (entry = rb->readdir(dir))) 70 while(0 != (entry = rb->readdir(dir)))
71 { 71 {
72 struct dirinfo info = rb->dir_get_info(dir, entry);
72 if(!rb->strcmp(entry->d_name, selected_file+dirlen)) 73 if(!rb->strcmp(entry->d_name, selected_file+dirlen))
73 { 74 {
74 unsigned log; 75 unsigned log;
75 rb->snprintf(str_dirname, sizeof str_dirname, "Path: %s", tstr); 76 rb->snprintf(str_dirname, sizeof str_dirname, "Path: %s", tstr);
76 rb->snprintf(str_filename, sizeof str_filename, "Name: %s", 77 rb->snprintf(str_filename, sizeof str_filename, "Name: %s",
77 selected_file+dirlen); 78 selected_file+dirlen);
78 log = human_size_log(entry->size); 79 log = human_size_log(info.size);
79 rb->snprintf(str_size, sizeof str_size, "Size: %ld %cB", 80 rb->snprintf(str_size, sizeof str_size, "Size: %ld %cB",
80 entry->size >> (log*10), human_size_prefix[log]); 81 info.size >> (log*10), human_size_prefix[log]);
81 rb->snprintf(str_date, sizeof str_date, "Date: %04d/%02d/%02d", 82 rb->snprintf(str_date, sizeof str_date, "Date: %04d/%02d/%02d",
82 ((entry->wrtdate >> 9 ) & 0x7F) + 1980, /* year */ 83 ((info.wrtdate >> 9 ) & 0x7F) + 1980, /* year */
83 ((entry->wrtdate >> 5 ) & 0x0F), /* month */ 84 ((info.wrtdate >> 5 ) & 0x0F), /* month */
84 ((entry->wrtdate ) & 0x1F)); /* day */ 85 ((info.wrtdate ) & 0x1F)); /* day */
85 rb->snprintf(str_time, sizeof str_time, "Time: %02d:%02d", 86 rb->snprintf(str_time, sizeof str_time, "Time: %02d:%02d",
86 ((entry->wrttime >> 11) & 0x1F), /* hour */ 87 ((info.wrttime >> 11) & 0x1F), /* hour */
87 ((entry->wrttime >> 5 ) & 0x3F)); /* minutes */ 88 ((info.wrttime >> 5 ) & 0x3F)); /* minutes */
88 89
89 num_properties = 5; 90 num_properties = 5;
90 91
@@ -158,11 +159,12 @@ static bool _dir_properties(DPS* dps)
158 /* walk through the directory content */ 159 /* walk through the directory content */
159 while(result && (0 != (entry = rb->readdir(dir)))) 160 while(result && (0 != (entry = rb->readdir(dir))))
160 { 161 {
162 struct dirinfo info = rb->dir_get_info(dir, entry);
161 /* append name to current directory */ 163 /* append name to current directory */
162 rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s", 164 rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s",
163 entry->d_name); 165 entry->d_name);
164 166
165 if (entry->attribute & ATTR_DIRECTORY) 167 if (info.attribute & ATTR_DIRECTORY)
166 { 168 {
167 unsigned log; 169 unsigned log;
168 170
@@ -188,7 +190,7 @@ static bool _dir_properties(DPS* dps)
188 else 190 else
189 { 191 {
190 dps->fc++; /* new file */ 192 dps->fc++; /* new file */
191 dps->bc += entry->size; 193 dps->bc += info.size;
192 } 194 }
193 if(ACTION_STD_CANCEL == rb->get_action(CONTEXT_STD,TIMEOUT_NOBLOCK)) 195 if(ACTION_STD_CANCEL == rb->get_action(CONTEXT_STD,TIMEOUT_NOBLOCK))
194 result = false; 196 result = false;
@@ -290,7 +292,8 @@ enum plugin_status plugin_start(const void* parameter)
290 { 292 {
291 if(!rb->strcmp(entry->d_name, file+dirlen)) 293 if(!rb->strcmp(entry->d_name, file+dirlen))
292 { 294 {
293 its_a_dir = entry->attribute & ATTR_DIRECTORY ? true : false; 295 struct dirinfo info = rb->dir_get_info(dir, entry);
296 its_a_dir = info.attribute & ATTR_DIRECTORY ? true : false;
294 found = true; 297 found = true;
295 break; 298 break;
296 } 299 }
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index 55d9bf99ab..eca33dc08a 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -98,7 +98,8 @@ void traversedir(char* location, char* name)
98 98
99 if (check) 99 if (check)
100 { 100 {
101 if (entry->attribute & ATTR_DIRECTORY) { 101 struct dirinfo info = rb->dir_get_info(dir, entry);
102 if (info.attribute & ATTR_DIRECTORY) {
102 char *start; 103 char *start;
103 dirs_count++; 104 dirs_count++;
104 rb->snprintf(path,MAX_PATH,"%s/%s",fullpath,entry->d_name); 105 rb->snprintf(path,MAX_PATH,"%s/%s",fullpath,entry->d_name);
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index ecf335d3f0..6a70a47ec4 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -178,7 +178,8 @@ void traversedir(char* location, char* name)
178 /* Skip .. and . */ 178 /* Skip .. and . */
179 if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, "..")) 179 if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, ".."))
180 { 180 {
181 if (entry->attribute & ATTR_DIRECTORY) { 181 struct dirinfo info = rb->dir_get_info(dir, entry);
182 if (info.attribute & ATTR_DIRECTORY) {
182 traversedir(fullpath, entry->d_name); 183 traversedir(fullpath, entry->d_name);
183 dirs++; 184 dirs++;
184 } 185 }
diff --git a/apps/plugins/theme_remove.c b/apps/plugins/theme_remove.c
index d679338ff8..674342a920 100644
--- a/apps/plugins/theme_remove.c
+++ b/apps/plugins/theme_remove.c
@@ -236,7 +236,8 @@ static int remove_dir(char* dirname, int len)
236 236
237 /* append name to current directory */ 237 /* append name to current directory */
238 rb->snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name); 238 rb->snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name);
239 if (entry->attribute & ATTR_DIRECTORY) 239 struct dirinfo info = rb->dir_get_info(dir, entry);
240 if (info.attribute & ATTR_DIRECTORY)
240 { 241 {
241 /* remove a subdirectory */ 242 /* remove a subdirectory */
242 if (!rb->strcmp((char *)entry->d_name, ".") || 243 if (!rb->strcmp((char *)entry->d_name, ".") ||