diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-09-01 21:29:34 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-09-01 21:29:34 +0000 |
commit | 6eaab4d00446c070c655f0e6c9a872532a776b6f (patch) | |
tree | 69610996dd0a6092459b14e164d4e48e03b1e5bb /apps | |
parent | 8e0a0babc57db3e9edc06f3e269fb47c27292ed5 (diff) |
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')
-rw-r--r-- | apps/codecs.c | 18 | ||||
-rw-r--r-- | apps/codecs.h | 2 | ||||
-rw-r--r-- | apps/codecs/sid.c | 6 | ||||
-rw-r--r-- | apps/filetree.c | 18 | ||||
-rw-r--r-- | apps/misc.c | 10 | ||||
-rw-r--r-- | apps/onplay.c | 9 | ||||
-rw-r--r-- | apps/plugin.c | 11 | ||||
-rw-r--r-- | apps/plugin.h | 3 | ||||
-rw-r--r-- | apps/plugins/disktidy.c | 11 | ||||
-rw-r--r-- | apps/plugins/lua/luadir.c | 3 | ||||
-rw-r--r-- | apps/plugins/md5sum.c | 4 | ||||
-rw-r--r-- | apps/plugins/properties.c | 23 | ||||
-rw-r--r-- | apps/plugins/random_folder_advance_config.c | 3 | ||||
-rw-r--r-- | apps/plugins/stats.c | 3 | ||||
-rw-r--r-- | apps/plugins/theme_remove.c | 3 | ||||
-rw-r--r-- | apps/tagcache.c | 6 | ||||
-rw-r--r-- | apps/tagtree.c | 2 |
17 files changed, 76 insertions, 59 deletions
diff --git a/apps/codecs.c b/apps/codecs.c index b072c65f40..25cc659e42 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -55,20 +55,16 @@ #define LOGF_ENABLE #include "logf.h" -#if (CONFIG_PLATFORM & PLATFORM_HOSTED) - +#if (CONFIG_PLATFORM & PLATFORM_SDL) #define PREFIX(_x_) sim_ ## _x_ +#else +#define PREFIX(_x_) _x_ +#endif + +#if (CONFIG_PLATFORM & PLATFORM_HOSTED) #if CONFIG_CODEC == SWCODEC unsigned char codecbuf[CODEC_SIZE]; #endif -void *sim_codec_load_ram(char* codecptr, int size, void **pd); -void sim_codec_close(void *pd); - -#else /* !PLATFORM_HOSTED */ - -#define PREFIX -#define sim_codec_close(x) - #endif size_t codec_size; @@ -110,7 +106,7 @@ struct codec_api ci = { #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE __div0, #endif - PREFIX(sleep), + sleep, yield, #if NUM_CORES > 1 diff --git a/apps/codecs.h b/apps/codecs.h index 97b33ec9ad..520aaeebc7 100644 --- a/apps/codecs.h +++ b/apps/codecs.h @@ -159,7 +159,7 @@ struct codec_api { #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE void (*__div0)(void); #endif - void (*sleep)(int ticks); + unsigned (*sleep)(unsigned ticks); void (*yield)(void); #if NUM_CORES > 1 diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c index 318cd1b4c8..455bdbc28a 100644 --- a/apps/codecs/sid.c +++ b/apps/codecs/sid.c @@ -101,7 +101,7 @@ void sidPoke(int reg, unsigned char val) ICODE_ATTR; #define rel 13 enum { - adc, _and, asl, bcc, bcs, beq, bit, bmi, bne, bpl, brk, bvc, bvs, clc, + adc, _and, asl, bcc, bcs, beq, bit, bmi, bne, bpl, _brk, bvc, bvs, clc, cld, cli, clv, cmp, cpx, cpy, dec, dex, dey, eor, inc, inx, iny, jmp, jsr, lda, ldx, ldy, lsr, _nop, ora, pha, php, pla, plp, rol, ror, rti, rts, sbc, sec, sed, sei, sta, stx, sty, tax, tay, tsx, txa, txs, tya, @@ -204,7 +204,7 @@ static const float decayReleaseTimes[16] ICONST_ATTR = }; static const int opcodes[256] ICONST_ATTR = { - brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx, + _brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx, bpl,ora,xxx,xxx,xxx,ora,asl,xxx,clc,ora,xxx,xxx,xxx,ora,asl,xxx, jsr,_and,xxx,xxx,bit,_and,rol,xxx,plp,_and,rol,xxx,bit,_and,rol,xxx, bmi,_and,xxx,xxx,xxx,_and,rol,xxx,sec,_and,xxx,xxx,xxx,_and,rol,xxx, @@ -908,7 +908,7 @@ static inline void cpuParse(void) setflags(FLAG_N,bval&0x80); setflags(FLAG_V,bval&0x40); break; - case brk: + case _brk: pc=0; /* Just quit the emulation */ break; case clc: diff --git a/apps/filetree.c b/apps/filetree.c index 0a1b49d1fe..1dc510f8c7 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -153,10 +153,10 @@ static void check_file_thumbnails(struct tree_context* c) while((entry = readdir(dir)) != 0) /* walk directory */ { int ext_pos; - + struct dirinfo info = dir_get_info(dir, entry); ext_pos = strlen((char *)entry->d_name) - strlen(file_thumbnail_ext); if (ext_pos <= 0 /* too short to carry ".talk" */ - || (entry->attribute & ATTR_DIRECTORY) /* no file */ + || (info.attribute & ATTR_DIRECTORY) /* no file */ || strcasecmp((char *)&entry->d_name[ext_pos], file_thumbnail_ext)) { /* or doesn't end with ".talk", no candidate */ continue; @@ -284,15 +284,17 @@ int ft_load(struct tree_context* c, const char* tempdir) for ( i=0; i < global_settings.max_files_in_dir; i++ ) { int len; struct dirent *entry = readdir(dir); + struct dirinfo info; struct entry* dptr = (struct entry*)(c->dircache + i * sizeof(struct entry)); if (!entry) break; + info = dir_get_info(dir, entry); len = strlen((char *)entry->d_name); /* skip directories . and .. */ - if ((entry->attribute & ATTR_DIRECTORY) && + if ((info.attribute & ATTR_DIRECTORY) && (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) || ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) { i--; @@ -300,7 +302,7 @@ int ft_load(struct tree_context* c, const char* tempdir) } /* Skip FAT volume ID */ - if (entry->attribute & ATTR_VOLUME_ID) { + if (info.attribute & ATTR_VOLUME_ID) { i--; continue; } @@ -308,12 +310,12 @@ int ft_load(struct tree_context* c, const char* tempdir) /* filter out dotfiles and hidden files */ if (*c->dirfilter != SHOW_ALL && ((entry->d_name[0]=='.') || - (entry->attribute & ATTR_HIDDEN))) { + (info.attribute & ATTR_HIDDEN))) { i--; continue; } - dptr->attr = entry->attribute; + dptr->attr = info.attribute; /* check for known file types */ if ( !(dptr->attr & ATTR_DIRECTORY) ) @@ -362,8 +364,8 @@ int ft_load(struct tree_context* c, const char* tempdir) } dptr->name = &c->name_buffer[name_buffer_used]; dptr->time_write = - (long)entry->wrtdate<<16 | - (long)entry->wrttime; /* in one # */ + (long)info.wrtdate<<16 | + (long)info.wrttime; /* in one # */ strcpy(dptr->name, (char *)entry->d_name); name_buffer_used += len + 1; diff --git a/apps/misc.c b/apps/misc.c index c35e2c5001..4b89a5d4a3 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -28,6 +28,7 @@ #include "misc.h" #include "lcd.h" #include "file.h" +#include "filefuncs.h" #ifndef __PCTOOL__ #include "lang.h" #include "dir.h" @@ -708,11 +709,12 @@ void check_bootfile(bool do_rolo) { if(!strcasecmp(entry->d_name, BOOTFILE)) { + struct dirinfo info = dir_get_info(dir, entry); /* found the bootfile */ if(wrtdate && do_rolo) { - if((entry->wrtdate != wrtdate) || - (entry->wrttime != wrttime)) + if((info.wrtdate != wrtdate) || + (info.wrttime != wrttime)) { static const char *lines[] = { ID2P(LANG_BOOT_CHANGED), ID2P(LANG_REBOOT_NOW) }; @@ -722,8 +724,8 @@ void check_bootfile(bool do_rolo) rolo_load(BOOTDIR "/" BOOTFILE); } } - wrtdate = entry->wrtdate; - wrttime = entry->wrttime; + wrtdate = info.wrtdate; + wrttime = info.wrttime; } } closedir(dir); diff --git a/apps/onplay.c b/apps/onplay.c index 72912579f9..f5b8476492 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -26,7 +26,6 @@ #include "debug.h" #include "lcd.h" -#include "dir.h" #include "file.h" #include "audio.h" #include "menu.h" @@ -63,6 +62,7 @@ #include "statusbar-skinned.h" #include "pitchscreen.h" #include "viewport.h" +#include "filefuncs.h" static int context; static char* selected_file = NULL; @@ -484,14 +484,14 @@ static int remove_dir(char* dirname, int len) entry = readdir(dir); if (!entry) break; - + struct dirinfo info = dir_get_info(dir, entry); dirname[dirlen] ='\0'; /* inform the user which dir we're deleting */ splash(0, dirname); /* append name to current directory */ snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name); - if (entry->attribute & ATTR_DIRECTORY) + if (info.attribute & ATTR_DIRECTORY) { /* remove a subdirectory */ if (!strcmp((char *)entry->d_name, ".") || !strcmp((char *)entry->d_name, "..")) @@ -783,6 +783,7 @@ static bool clipboard_pastedirectory(char *src, int srclen, char *target, if (!entry) break; + struct dirinfo info = dir_get_info(srcdir, entry); /* append name to current directory */ snprintf(src+srcdirlen, srclen-srcdirlen, "/%s", entry->d_name); snprintf(target+targetdirlen, targetlen-targetdirlen, "/%s", @@ -790,7 +791,7 @@ static bool clipboard_pastedirectory(char *src, int srclen, char *target, DEBUGF("Copy %s to %s\n", src, target); - if (entry->attribute & ATTR_DIRECTORY) + if (info.attribute & ATTR_DIRECTORY) { /* copy/move a subdirectory */ if (!strcmp((char *)entry->d_name, ".") || !strcmp((char *)entry->d_name, "..")) diff --git a/apps/plugin.c b/apps/plugin.c index e0455c51a2..9e08951828 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -59,7 +59,7 @@ #include "usbstack/usb_hid.h" #endif -#if (CONFIG_PLATFORM & PLATFORM_HOSTED) +#if (CONFIG_PLATFORM & PLATFORM_SDL) #define PREFIX(_x_) sim_ ## _x_ #else #define PREFIX @@ -349,7 +349,7 @@ static const struct plugin_api rockbox_api = { #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE __div0, #endif - PREFIX(sleep), + sleep, yield, ¤t_tick, default_event_handler, @@ -529,7 +529,7 @@ static const struct plugin_api rockbox_api = { playlist_insert_track, playlist_insert_directory, playlist_shuffle, - PREFIX(audio_play), + audio_play, audio_stop, audio_pause, audio_resume, @@ -722,6 +722,7 @@ static const struct plugin_api rockbox_api = { /* new stuff at the end, sort into place next time the API gets incompatible */ + dir_get_info, }; int plugin_load(const char* plugin, const void* parameter) @@ -940,11 +941,11 @@ static int open_wrapper(const char* pathname, int flags, ...) { va_list ap; va_start(ap, flags); - fd = sim_open(pathname, flags, va_arg(ap, unsigned int)); + fd = open(pathname, flags, va_arg(ap, unsigned int)); va_end(ap); } else - fd = sim_open(pathname, flags); + fd = open(pathname, flags); #else fd = file_open(pathname,flags); #endif diff --git a/apps/plugin.h b/apps/plugin.h index 422f58fc8a..ddd913088f 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -459,7 +459,7 @@ struct plugin_api { #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE void (*__div0)(void); #endif - void (*sleep)(int ticks); + unsigned (*sleep)(unsigned ticks); void (*yield)(void); volatile long* current_tick; long (*default_event_handler)(long event); @@ -894,6 +894,7 @@ struct plugin_api { /* new stuff at the end, sort into place next time the API gets incompatible */ + struct dirinfo (*dir_get_info)(struct DIR* parent, struct dirent *entry); }; /* plugin header */ 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) /* 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 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) { 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 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 ) 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 d6692bc893..e127a2908e 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 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) 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 ecf335d3f0..6a70a47ec4 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 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) /* 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, ".") || diff --git a/apps/tagcache.c b/apps/tagcache.c index 6e416dd7f8..a6cfb4c590 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -4222,6 +4222,8 @@ static bool check_dir(const char *dirname, int add_files) success = true; break ; } + + struct dirinfo info = dir_get_info(dir, entry); if (!strcmp((char *)entry->d_name, ".") || !strcmp((char *)entry->d_name, "..")) @@ -4234,14 +4236,14 @@ static bool check_dir(const char *dirname, int add_files) entry->d_name); processed_dir_count++; - if (entry->attribute & ATTR_DIRECTORY) + if (info.attribute & ATTR_DIRECTORY) check_dir(curpath, add_files); else if (add_files) { tc_stat.curentry = curpath; /* Add a new entry to the temporary db file. */ - add_tagcache(curpath, (entry->wrtdate << 16) | entry->wrttime + add_tagcache(curpath, (info.wrtdate << 16) | info.wrttime #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) , dir->internal_entry #endif diff --git a/apps/tagtree.c b/apps/tagtree.c index 8c7f7a2e5d..78c48b4d13 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -51,7 +51,7 @@ #include "audio.h" #include "appevents.h" #include "storage.h" -#include "dir_uncached.h" +#include "dir.h" #define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" |