From 6eaab4d00446c070c655f0e6c9a872532a776b6f Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Wed, 1 Sep 2010 21:29:34 +0000 Subject: 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 --- apps/plugins/disktidy.c | 11 +++++++---- apps/plugins/lua/luadir.c | 3 ++- apps/plugins/md5sum.c | 4 +++- apps/plugins/properties.c | 23 +++++++++++++---------- apps/plugins/random_folder_advance_config.c | 3 ++- apps/plugins/stats.c | 3 ++- apps/plugins/theme_remove.c | 3 ++- 7 files changed, 31 insertions(+), 19 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c index c5f0f4a..1e6c153 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) /* silent error */ continue; - if (entry->attribute & ATTR_DIRECTORY) + + struct dirinfo info = rb->dir_get_info(dir, entry); + if (info.attribute & ATTR_DIRECTORY) { /* dir ignore "." and ".." */ if ((rb->strcmp(entry->d_name, ".") != 0) && \ @@ -297,6 +299,7 @@ enum tidy_return tidy_clean(char *path, int *path_length) while((status == TIDY_RETURN_OK) && ((entry = rb->readdir(dir)) != 0)) /* walk directory */ { + struct dirinfo info = rb->dir_get_info(dir, entry); /* check for user input and usb connect */ button = rb->get_action(CONTEXT_STD, TIMEOUT_NOBLOCK); if (button == ACTION_STD_CANCEL) @@ -312,7 +315,7 @@ enum tidy_return tidy_clean(char *path, int *path_length) rb->yield(); - if (entry->attribute & ATTR_DIRECTORY) + if (info.attribute & ATTR_DIRECTORY) { /* directory ignore "." and ".." */ if ((rb->strcmp(entry->d_name, ".") != 0) && \ @@ -326,7 +329,7 @@ enum tidy_return tidy_clean(char *path, int *path_length) /* silent error */ continue; - if (tidy_remove_item(entry->d_name, entry->attribute)) + if (tidy_remove_item(entry->d_name, info.attribute)) { /* delete dir */ tidy_removedir(path, path_length); @@ -347,7 +350,7 @@ enum tidy_return tidy_clean(char *path, int *path_length) { /* file */ del = 0; - if (tidy_remove_item(entry->d_name, entry->attribute)) + if (tidy_remove_item(entry->d_name, info.attribute)) { /* get absolute path */ /* returns an error if path is too long */ diff --git a/apps/plugins/lua/luadir.c b/apps/plugins/lua/luadir.c index 730c40c..c8c21d2 100644 --- a/apps/plugins/lua/luadir.c +++ b/apps/plugins/lua/luadir.c @@ -56,8 +56,9 @@ static int dir_iter (lua_State *L) { luaL_argcheck (L, !d->closed, 1, "closed directory"); if ((entry = rb->readdir (d->dir)) != NULL) { + struct dirinfo info = rb->dir_get_info(d->dir, entry); lua_pushstring (L, entry->d_name); - lua_pushboolean (L, entry->attribute & ATTR_DIRECTORY); + lua_pushboolean (L, info.attribute & ATTR_DIRECTORY); return 2; } else { /* no more entries => close directory */ diff --git a/apps/plugins/md5sum.c b/apps/plugins/md5sum.c index fe1c65e..c993018 100644 --- a/apps/plugins/md5sum.c +++ b/apps/plugins/md5sum.c @@ -95,7 +95,9 @@ static void hash_dir( int out, const char *path ) char childpath[MAX_PATH]; rb->snprintf( childpath, MAX_PATH, "%s/%s", rb->strcmp( path, "/" ) ? path : "", entry->d_name ); - if( entry->attribute & ATTR_DIRECTORY ) + + struct dirinfo info = rb->dir_get_info(dir, entry); + if (info.attribute & ATTR_DIRECTORY) { if( rb->strcmp( entry->d_name, "." ) && rb->strcmp( entry->d_name, ".." ) ) diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index d6692bc..e127a29 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c @@ -69,22 +69,23 @@ static bool file_properties(char* selected_file) { while(0 != (entry = rb->readdir(dir))) { + struct dirinfo info = rb->dir_get_info(dir, entry); if(!rb->strcmp(entry->d_name, selected_file+dirlen)) { unsigned log; rb->snprintf(str_dirname, sizeof str_dirname, "Path: %s", tstr); rb->snprintf(str_filename, sizeof str_filename, "Name: %s", selected_file+dirlen); - log = human_size_log(entry->size); + log = human_size_log(info.size); rb->snprintf(str_size, sizeof str_size, "Size: %ld %cB", - entry->size >> (log*10), human_size_prefix[log]); + info.size >> (log*10), human_size_prefix[log]); rb->snprintf(str_date, sizeof str_date, "Date: %04d/%02d/%02d", - ((entry->wrtdate >> 9 ) & 0x7F) + 1980, /* year */ - ((entry->wrtdate >> 5 ) & 0x0F), /* month */ - ((entry->wrtdate ) & 0x1F)); /* day */ + ((info.wrtdate >> 9 ) & 0x7F) + 1980, /* year */ + ((info.wrtdate >> 5 ) & 0x0F), /* month */ + ((info.wrtdate ) & 0x1F)); /* day */ rb->snprintf(str_time, sizeof str_time, "Time: %02d:%02d", - ((entry->wrttime >> 11) & 0x1F), /* hour */ - ((entry->wrttime >> 5 ) & 0x3F)); /* minutes */ + ((info.wrttime >> 11) & 0x1F), /* hour */ + ((info.wrttime >> 5 ) & 0x3F)); /* minutes */ num_properties = 5; @@ -158,11 +159,12 @@ static bool _dir_properties(DPS* dps) /* walk through the directory content */ while(result && (0 != (entry = rb->readdir(dir)))) { + struct dirinfo info = rb->dir_get_info(dir, entry); /* append name to current directory */ rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s", entry->d_name); - if (entry->attribute & ATTR_DIRECTORY) + if (info.attribute & ATTR_DIRECTORY) { unsigned log; @@ -188,7 +190,7 @@ static bool _dir_properties(DPS* dps) else { dps->fc++; /* new file */ - dps->bc += entry->size; + dps->bc += info.size; } if(ACTION_STD_CANCEL == rb->get_action(CONTEXT_STD,TIMEOUT_NOBLOCK)) result = false; @@ -290,7 +292,8 @@ enum plugin_status plugin_start(const void* parameter) { if(!rb->strcmp(entry->d_name, file+dirlen)) { - its_a_dir = entry->attribute & ATTR_DIRECTORY ? true : false; + struct dirinfo info = rb->dir_get_info(dir, entry); + its_a_dir = info.attribute & ATTR_DIRECTORY ? true : false; found = true; break; } diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 55d9bf9..eca33dc 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) if (check) { - if (entry->attribute & ATTR_DIRECTORY) { + struct dirinfo info = rb->dir_get_info(dir, entry); + if (info.attribute & ATTR_DIRECTORY) { char *start; dirs_count++; rb->snprintf(path,MAX_PATH,"%s/%s",fullpath,entry->d_name); diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c index ecf335d..6a70a47 100644 --- a/apps/plugins/stats.c +++ b/apps/plugins/stats.c @@ -178,7 +178,8 @@ void traversedir(char* location, char* name) /* Skip .. and . */ if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, "..")) { - if (entry->attribute & ATTR_DIRECTORY) { + struct dirinfo info = rb->dir_get_info(dir, entry); + if (info.attribute & ATTR_DIRECTORY) { traversedir(fullpath, entry->d_name); dirs++; } diff --git a/apps/plugins/theme_remove.c b/apps/plugins/theme_remove.c index d679338..674342a 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) /* append name to current directory */ rb->snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name); - if (entry->attribute & ATTR_DIRECTORY) + struct dirinfo info = rb->dir_get_info(dir, entry); + if (info.attribute & ATTR_DIRECTORY) { /* remove a subdirectory */ if (!rb->strcmp((char *)entry->d_name, ".") || -- cgit v1.1