summaryrefslogtreecommitdiffstats
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
parent8e0a0babc57db3e9edc06f3e269fb47c27292ed5 (diff)
downloadrockbox-6eaab4d00446c070c655f0e6c9a872532a776b6f.tar.gz
rockbox-6eaab4d00446c070c655f0e6c9a872532a776b6f.tar.bz2
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
-rw-r--r--apps/codecs.c18
-rw-r--r--apps/codecs.h2
-rw-r--r--apps/codecs/sid.c6
-rw-r--r--apps/filetree.c18
-rw-r--r--apps/misc.c10
-rw-r--r--apps/onplay.c9
-rw-r--r--apps/plugin.c11
-rw-r--r--apps/plugin.h3
-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
-rw-r--r--apps/tagcache.c6
-rw-r--r--apps/tagtree.c2
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/common/dir_uncached.c10
-rw-r--r--firmware/common/dircache.c79
-rw-r--r--firmware/common/file.c8
-rw-r--r--firmware/common/filefuncs.c9
-rw-r--r--firmware/export/audio.h5
-rw-r--r--firmware/export/config.h2
-rw-r--r--firmware/export/filefuncs.h3
-rw-r--r--firmware/export/kernel.h6
-rw-r--r--firmware/general.c2
-rw-r--r--firmware/include/dir.h13
-rw-r--r--firmware/include/dir_uncached.h26
-rw-r--r--firmware/include/dircache.h10
-rw-r--r--firmware/include/file.h2
-rw-r--r--firmware/kernel.c3
-rw-r--r--firmware/target/hosted/android/dir-target.h37
-rw-r--r--firmware/target/hosted/android/fs-android.c129
-rw-r--r--firmware/target/hosted/android/lc-android.c40
-rw-r--r--uisimulator/common/SOURCES4
-rw-r--r--uisimulator/common/io.c21
37 files changed, 389 insertions, 157 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,
&current_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"
diff --git a/firmware/SOURCES b/firmware/SOURCES
index f83b78970e..8b71674b36 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1703,7 +1703,9 @@ target/coldfire/mpio/fmradio_i2c-mpio.c
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
+target/hosted/android/fs-android.c
target/hosted/android/lcd-android.c
+target/hosted/android/lc-android.c
target/hosted/android/button-android.c
target/hosted/android/kernel-android.c
target/hosted/android/pcm-android.c
diff --git a/firmware/common/dir_uncached.c b/firmware/common/dir_uncached.c
index e3e33a4c11..2ce23e8b8e 100644
--- a/firmware/common/dir_uncached.c
+++ b/firmware/common/dir_uncached.c
@@ -171,7 +171,7 @@ struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir)
if (fat_ismounted(dir->volumecounter))
{
memset(theent, 0, sizeof(*theent));
- theent->attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME;
+ theent->info.attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME;
snprintf(theent->d_name, sizeof(theent->d_name),
VOL_NAMES, dir->volumecounter);
return theent;
@@ -187,11 +187,11 @@ struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir)
return NULL;
strlcpy(theent->d_name, entry.name, sizeof(theent->d_name));
- theent->attribute = entry.attr;
- theent->size = entry.filesize;
+ theent->info.attribute = entry.attr;
+ theent->info.wrtdate = entry.wrtdate;
+ theent->info.wrttime = entry.wrttime;
+ theent->info.size = entry.filesize;
theent->startcluster = entry.firstcluster;
- theent->wrtdate = entry.wrtdate;
- theent->wrttime = entry.wrttime;
return theent;
}
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 4ae8d805dd..509743bdbb 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -237,19 +237,19 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
!strcmp("..", sab.direntry->name))
continue;
- ce->attribute = sab.direntry->attr;
ce->name_len = strlen(sab.direntry->name) + 1;
ce->d_name = ((char *)dircache_root + dircache_size);
ce->startcluster = sab.direntry->firstcluster;
- ce->size = sab.direntry->filesize;
- ce->wrtdate = sab.direntry->wrtdate;
- ce->wrttime = sab.direntry->wrttime;
+ ce->info.size = sab.direntry->filesize;
+ ce->info.attribute = sab.direntry->attr;
+ ce->info.wrtdate = sab.direntry->wrtdate;
+ ce->info.wrttime = sab.direntry->wrttime;
memcpy(ce->d_name, sab.direntry->name, ce->name_len);
dircache_size += ce->name_len;
entry_count++;
- if(ce->attribute & FAT_ATTR_DIRECTORY)
+ if(ce->info.attribute & FAT_ATTR_DIRECTORY)
dircache_gen_down(ce);
ce = dircache_gen_next(ce);
@@ -269,18 +269,18 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
/* add "." and ".." */
ce->d_name = ".";
ce->name_len = 2;
- ce->attribute = FAT_ATTR_DIRECTORY;
+ ce->info.attribute = FAT_ATTR_DIRECTORY;
ce->startcluster = startcluster;
- ce->size = 0;
+ ce->info.size = 0;
ce->down = first_ce;
ce = dircache_gen_next(ce);
ce->d_name = "..";
ce->name_len = 3;
- ce->attribute = FAT_ATTR_DIRECTORY;
+ ce->info.attribute = FAT_ATTR_DIRECTORY;
ce->startcluster = (first_ce->up ? first_ce->up->startcluster : 0);
- ce->size = 0;
+ ce->info.size = 0;
ce->down = first_ce->up;
/* second pass: recurse ! */
@@ -311,8 +311,8 @@ static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce
snprintf(ce->d_name, VOL_ENUM_POS + 3, VOL_NAMES, volume);
ce->name_len = VOL_ENUM_POS + 3;
dircache_size += ce->name_len;
- ce->attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME;
- ce->size = 0;
+ ce->info.attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME;
+ ce->info.size = 0;
append_position = dircache_gen_next(ce);
ce = dircache_gen_down(ce);
}
@@ -347,18 +347,15 @@ static int sab_process_dir(struct dircache_entry *ce)
!strcmp("..", entry->d_name))
continue;
- ce->attribute = entry->attribute;
ce->name_len = strlen(entry->d_name) + 1;
ce->d_name = ((char *)dircache_root + dircache_size);
- ce->size = entry->size;
- ce->wrtdate = entry->wrtdate;
- ce->wrttime = entry->wrttime;
+ ce->info = entry->info;
memcpy(ce->d_name, entry->d_name, ce->name_len);
dircache_size += ce->name_len;
entry_count++;
- if(entry->attribute & ATTR_DIRECTORY)
+ if(entry->info.attribute & ATTR_DIRECTORY)
{
dircache_gen_down(ce);
if(ce->down == NULL)
@@ -400,16 +397,16 @@ static int sab_process_dir(struct dircache_entry *ce)
/* add "." and ".." */
ce->d_name = ".";
ce->name_len = 2;
- ce->attribute = ATTR_DIRECTORY;
- ce->size = 0;
+ ce->info.attribute = ATTR_DIRECTORY;
+ ce->info.size = 0;
ce->down = first_ce;
ce = dircache_gen_next(ce);
ce->d_name = "..";
ce->name_len = 3;
- ce->attribute = ATTR_DIRECTORY;
- ce->size = 0;
+ ce->info.attribute = ATTR_DIRECTORY;
+ ce->info.size = 0;
ce->down = first_ce->up;
closedir_uncached(dir);
@@ -1022,13 +1019,11 @@ static struct dircache_entry* dircache_new_entry(const char *path, int attribute
return NULL;
}
- entry->attribute = attribute;
entry->name_len = MIN(254, strlen(new)) + 1;
entry->d_name = ((char *)dircache_root+dircache_size);
entry->startcluster = 0;
- entry->wrtdate = 0;
- entry->wrttime = 0;
- entry->size = 0;
+ memset(&entry->info, 0, sizeof(entry->info));
+ entry->info.attribute = attribute;
memcpy(entry->d_name, new, entry->name_len);
dircache_size += entry->name_len;
@@ -1086,7 +1081,7 @@ void dircache_update_filesize(int fd, long newsize, long startcluster)
return ;
}
- fd_bindings[fd]->size = newsize;
+ fd_bindings[fd]->info.size = newsize;
fd_bindings[fd]->startcluster = startcluster;
}
void dircache_update_filetime(int fd)
@@ -1106,12 +1101,12 @@ void dircache_update_filetime(int fd)
return ;
}
year = now->tm_year+1900-1980;
- fd_bindings[fd]->wrtdate = (((year)&0x7f)<<9) |
- (((now->tm_mon+1)&0xf)<<5) |
- (((now->tm_mday)&0x1f));
- fd_bindings[fd]->wrttime = (((now->tm_hour)&0x1f)<<11) |
- (((now->tm_min)&0x3f)<<5) |
- (((now->tm_sec/2)&0x1f));
+ fd_bindings[fd]->info.wrtdate = (((year)&0x7f)<<9) |
+ (((now->tm_mon+1)&0xf)<<5) |
+ (((now->tm_mday)&0x1f));
+ fd_bindings[fd]->info.wrttime = (((now->tm_hour)&0x1f)<<11) |
+ (((now->tm_min)&0x3f)<<5) |
+ (((now->tm_sec/2)&0x1f));
#endif
}
@@ -1211,7 +1206,7 @@ void dircache_rename(const char *oldpath, const char *newpath)
newpath = absolute_path;
}
- newentry = dircache_new_entry(newpath, entry->attribute);
+ newentry = dircache_new_entry(newpath, entry->info.attribute);
if (newentry == NULL)
{
dircache_initialized = false;
@@ -1219,10 +1214,10 @@ void dircache_rename(const char *oldpath, const char *newpath)
}
newentry->down = oldentry.down;
- newentry->size = oldentry.size;
newentry->startcluster = oldentry.startcluster;
- newentry->wrttime = oldentry.wrttime;
- newentry->wrtdate = oldentry.wrtdate;
+ newentry->info.size = oldentry.info.size;
+ newentry->info.wrtdate = oldentry.info.wrtdate;
+ newentry->info.wrttime = oldentry.info.wrttime;
}
void dircache_add_file(const char *path, long startcluster)
@@ -1279,7 +1274,7 @@ DIR_CACHED* opendir_cached(const char* name)
{
pdir->regulardir = NULL;
pdir->internal_entry = dircache_get_entry(name, true);
- pdir->theent.attribute = -1; /* used to make readdir_cached aware of the first call */
+ pdir->theent.info.attribute = -1; /* used to make readdir_cached aware of the first call */
}
if (pdir->internal_entry == NULL && pdir->regulardir == NULL)
@@ -1306,11 +1301,8 @@ struct dirent_cached* readdir_cached(DIR_CACHED* dir)
return NULL;
strlcpy(dir->theent.d_name, regentry->d_name, MAX_PATH);
- dir->theent.size = regentry->size;
dir->theent.startcluster = regentry->startcluster;
- dir->theent.attribute = regentry->attribute;
- dir->theent.wrttime = regentry->wrttime;
- dir->theent.wrtdate = regentry->wrtdate;
+ dir->theent.info = regentry->info;
return &dir->theent;
}
@@ -1318,7 +1310,7 @@ struct dirent_cached* readdir_cached(DIR_CACHED* dir)
/* if theent.attribute=-1 then this is the first call */
/* otherwise, this is is not so we first take the entry's ->next */
/* NOTE: normal file can't have attribute=-1 */
- if(dir->theent.attribute != -1)
+ if(dir->theent.info.attribute != -1)
ce = ce->next;
/* skip unused entries */
while(ce != NULL && ce->name_len == 0)
@@ -1330,11 +1322,8 @@ struct dirent_cached* readdir_cached(DIR_CACHED* dir)
strlcpy(dir->theent.d_name, ce->d_name, MAX_PATH);
/* Can't do `dir->theent = *ce`
because that modifies the d_name pointer. */
- dir->theent.size = ce->size;
dir->theent.startcluster = ce->startcluster;
- dir->theent.attribute = ce->attribute;
- dir->theent.wrttime = ce->wrttime;
- dir->theent.wrtdate = ce->wrtdate;
+ dir->theent.info = ce->info;
dir->internal_entry = ce;
//logf("-> %s", ce->name);
diff --git a/firmware/common/file.c b/firmware/common/file.c
index 6beec9f606..53a1a35b31 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -124,8 +124,8 @@ static int open_internal(const char* pathname, int flags, bool use_cache)
ce->startcluster,
&(file->fatfile),
NULL);
- file->size = ce->size;
- file->attr = ce->attribute;
+ file->size = ce->info.size;
+ file->attr = ce->info.attribute;
file->cacheoffset = -1;
file->fileoffset = 0;
@@ -169,8 +169,8 @@ static int open_internal(const char* pathname, int flags, bool use_cache)
entry->startcluster,
&(file->fatfile),
&(dir->fatdir));
- file->size = file->trunc ? 0 : entry->size;
- file->attr = entry->attribute;
+ file->size = file->trunc ? 0 : entry->info.size;
+ file->attr = entry->info.attribute;
break;
}
}
diff --git a/firmware/common/filefuncs.c b/firmware/common/filefuncs.c
index 9fe07d69bb..c8ab468bcb 100644
--- a/firmware/common/filefuncs.c
+++ b/firmware/common/filefuncs.c
@@ -23,6 +23,7 @@
#include "stdlib.h"
#include "string.h"
#include "debug.h"
+#include "file.h"
#include "filefuncs.h"
#ifdef HAVE_MULTIVOLUME
@@ -87,4 +88,12 @@ bool dir_exists(const char *path)
closedir(d);
return true;
}
+
+#if !(CONFIG_PLATFORM & PLATFORM_ANDROID)
+struct dirinfo dir_get_info(struct DIR* parent, struct dirent *entry)
+{
+ (void)parent;
+ return entry->info;
+}
+#endif
#endif /* __PCTOOL__ */
diff --git a/firmware/export/audio.h b/firmware/export/audio.h
index b81597a892..34bcfb6b8f 100644
--- a/firmware/export/audio.h
+++ b/firmware/export/audio.h
@@ -35,11 +35,6 @@
#endif /* HAVE_RECORDING */
#endif /* CONFIG_CODEC == SWCODEC */
-
-#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
-#define audio_play(x) sim_audio_play(x)
-#endif
-
#define AUDIO_STATUS_PLAY 0x0001
#define AUDIO_STATUS_PAUSE 0x0002
#define AUDIO_STATUS_RECORD 0x0004
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 83a9ea4feb..b81c684526 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -664,7 +664,7 @@ Lyre prototype 1 */
/* Enable the directory cache and tagcache in RAM if we have
* plenty of RAM. Both features can be enabled independently. */
#if ((defined(MEMORYSIZE) && (MEMORYSIZE >= 8)) || MEM >= 8) && \
- !defined(BOOTLOADER) && !defined(__PCTOOL__)
+ !defined(BOOTLOADER) && !defined(__PCTOOL__) && !defined(APPLICATION)
#define HAVE_DIRCACHE
#ifdef HAVE_TAGCACHE
#define HAVE_TC_RAMCACHE
diff --git a/firmware/export/filefuncs.h b/firmware/export/filefuncs.h
index 3745c6bee3..f69c6da29c 100644
--- a/firmware/export/filefuncs.h
+++ b/firmware/export/filefuncs.h
@@ -22,7 +22,9 @@
#ifndef __INCLUDE_FILEFUNCS_H_
#define __INCLUDE_FILEFUNCS_H_
+#include <stdbool.h>
#include "config.h"
+#include "dir.h"
#ifdef HAVE_MULTIVOLUME
int strip_volume(const char* name, char* namecopy);
@@ -32,5 +34,6 @@ int strip_volume(const char* name, char* namecopy);
bool file_exists(const char *file);
bool dir_exists(const char *path);
#endif
+extern struct dirinfo dir_get_info(struct DIR* parent, struct dirent *entry);
#endif /* __INCLUDE_FILEFUNCS_H_ */
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h
index d256f31ab5..405f6b6838 100644
--- a/firmware/export/kernel.h
+++ b/firmware/export/kernel.h
@@ -203,14 +203,10 @@ static inline void call_tick_tasks(void)
}
#endif
-#if (CONFIG_PLATFORM & PLATFORM_HOSTED) && !defined(PLUGIN) && !defined(CODEC)
-#define sleep(x) sim_sleep(x)
-#endif
-
/* kernel functions */
extern void kernel_init(void) INIT_ATTR;
extern void yield(void);
-extern void sleep(int ticks);
+extern unsigned sleep(unsigned ticks);
int tick_add_task(void (*f)(void));
int tick_remove_task(void (*f)(void));
extern void tick_start(unsigned int interval_in_ms) INIT_ATTR;
diff --git a/firmware/general.c b/firmware/general.c
index 20b0277c09..3daf2f0a78 100644
--- a/firmware/general.c
+++ b/firmware/general.c
@@ -22,7 +22,7 @@
#include "config.h"
#include <stdio.h>
#include "general.h"
-
+#include "file.h"
#include "dir.h"
#include "limits.h"
#include "stdlib.h"
diff --git a/firmware/include/dir.h b/firmware/include/dir.h
index 9ff96e3419..d143ed2664 100644
--- a/firmware/include/dir.h
+++ b/firmware/include/dir.h
@@ -41,6 +41,15 @@
#endif
+#define ATTR_READ_ONLY 0x01
+#define ATTR_HIDDEN 0x02
+#define ATTR_SYSTEM 0x04
+#define ATTR_VOLUME_ID 0x08
+#define ATTR_DIRECTORY 0x10
+#define ATTR_ARCHIVE 0x20
+#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
+
+#if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL))
#ifdef HAVE_DIRCACHE
# include "dircache.h"
# define DIR DIR_CACHED
@@ -62,5 +71,9 @@
# define mkdir mkdir_uncached
# define rmdir rmdir_uncached
#endif
+#else
+#include "dir_uncached.h"
+#include "dir-target.h"
+#endif
#endif
diff --git a/firmware/include/dir_uncached.h b/firmware/include/dir_uncached.h
index f225cf8e39..5c7ed14658 100644
--- a/firmware/include/dir_uncached.h
+++ b/firmware/include/dir_uncached.h
@@ -21,18 +21,20 @@
#ifndef _DIR_UNCACHED_H_
#define _DIR_UNCACHED_H_
+#include "config.h"
+
+struct dirinfo {
+ int attribute;
+ long size;
+ unsigned short wrtdate;
+ unsigned short wrttime;
+};
+
+#ifndef APPLICATION
#include <stdbool.h>
#include "file.h"
-#define ATTR_READ_ONLY 0x01
-#define ATTR_HIDDEN 0x02
-#define ATTR_SYSTEM 0x04
-#define ATTR_VOLUME_ID 0x08
-#define ATTR_DIRECTORY 0x10
-#define ATTR_ARCHIVE 0x20
-#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
-
-#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
+#if (CONFIG_PLATFORM & PLATFORM_SDL)
#define dirent_uncached sim_dirent
#define DIR_UNCACHED SIM_DIR
#define opendir_uncached sim_opendir
@@ -46,11 +48,8 @@
struct dirent_uncached {
unsigned char d_name[MAX_PATH];
- int attribute;
- long size;
+ struct dirinfo info;
long startcluster;
- unsigned short wrtdate; /* Last write date */
- unsigned short wrttime; /* Last write time */
};
#endif
@@ -92,5 +91,6 @@ extern struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir);
extern int release_dirs(int volume);
#endif /* DIRFUNCTIONS_DEFINED */
+#endif
#endif
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h
index 650b92632d..37a803c63c 100644
--- a/firmware/include/dircache.h
+++ b/firmware/include/dircache.h
@@ -63,25 +63,19 @@ struct fdbind_queue {
/* Exported structures. */
struct dircache_entry {
+ struct dirinfo info;
struct dircache_entry *next;
struct dircache_entry *up;
struct dircache_entry *down;
- int attribute;
- long size;
long startcluster;
- unsigned short wrtdate;
- unsigned short wrttime;
unsigned long name_len;
char *d_name;
};
struct dirent_cached {
+ struct dirinfo info;
char *d_name;
- int attribute;
- long size;
long startcluster;
- unsigned short wrtdate; /* Last write date */
- unsigned short wrttime; /* Last write time */
};
typedef struct {
diff --git a/firmware/include/file.h b/firmware/include/file.h
index 8a084d6f39..8711124391 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -37,7 +37,7 @@
#define MAX_OPEN_FILES 11
#if !defined(PLUGIN) && !defined(CODEC)
-#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
+#if (CONFIG_PLATFORM & PLATFORM_SDL)
#define open(x, ...) sim_open(x, __VA_ARGS__)
#define creat(x,m) sim_creat(x,m)
#define remove(x) sim_remove(x)
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 1499402f40..9d72a7eeda 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -213,7 +213,7 @@ void timeout_register(struct timeout *tmo, timeout_cb_type callback,
/****************************************************************************
* Thread stuff
****************************************************************************/
-void sleep(int ticks)
+unsigned sleep(unsigned ticks)
{
#if defined(CPU_PP) && defined(BOOTLOADER)
unsigned stop = USEC_TIMER + ticks * (1000000/HZ);
@@ -229,6 +229,7 @@ void sleep(int ticks)
sleep_thread(ticks);
switch_thread();
#endif
+ return 0;
}
void yield(void)
diff --git a/firmware/target/hosted/android/dir-target.h b/firmware/target/hosted/android/dir-target.h
new file mode 100644
index 0000000000..4516215d62
--- /dev/null
+++ b/firmware/target/hosted/android/dir-target.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __DIR_TARGET_H__
+#define __DIR_TARGET_H__
+
+#include <dirent.h>
+
+#define opendir _opendir
+#define mkdir _mkdir
+#define closedir _closedir
+#define readdir _readdir
+
+extern DIR* _opendir(const char* name);
+extern int _mkdir(const char* name);
+extern int _closedir(DIR* dir);
+extern struct dirent *_readdir(DIR* dir);
+
+#endif /* __DIR_TARGET_H__ */
diff --git a/firmware/target/hosted/android/fs-android.c b/firmware/target/hosted/android/fs-android.c
new file mode 100644
index 0000000000..5209458e54
--- /dev/null
+++ b/firmware/target/hosted/android/fs-android.c
@@ -0,0 +1,129 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <sys/stat.h> /* stat() */
+#include <stdio.h> /* snprintf */
+#include <string.h> /* size_t */
+#include <dirent.h>
+#include <time.h> /* localtime() */
+#include "system-target.h"
+#include "dir-target.h"
+#include "file.h"
+#include "dir.h"
+
+
+long filesize(int fd)
+{
+ struct stat buf;
+
+ if (!fstat(fd, &buf))
+ return buf.st_size;
+ else
+ return -1;
+}
+
+/* do we really need this in the app? */
+void fat_size(unsigned long* size, unsigned long* free)
+{
+ *size = *free = 0;
+}
+
+#undef opendir
+#undef closedir
+#undef mkdir
+#undef readdir
+
+/* need to wrap around DIR* because we need to save the parent's
+ * directory path in order to determine dirinfo */
+struct __dir {
+ DIR *dir;
+ char *path;
+};
+
+DIR* _opendir(const char *name)
+{
+ char *buf = malloc(sizeof(struct __dir) + strlen(name)+1);
+ if (!buf)
+ return NULL;
+
+ struct __dir *this = (struct __dir*)buf;
+
+ this->path = buf+sizeof(struct __dir);
+ /* definitely fits due to strlen() */
+ strcpy(this->path, name);
+
+ this->dir = opendir(name);
+
+ if (!this->dir)
+ {
+ free(buf);
+ return NULL;
+ }
+ return (DIR*)this;
+}
+
+int _mkdir(const char *name)
+{
+ return mkdir(name, 0777);
+}
+
+int _closedir(DIR *dir)
+{
+ struct __dir *this = (struct __dir*)dir;
+ int ret = closedir(this->dir);
+ free(this);
+ return ret;
+}
+
+struct dirent* _readdir(DIR* dir)
+{
+ struct __dir *d = (struct __dir*)dir;
+ return readdir(d->dir);
+}
+
+struct dirinfo dir_get_info(struct DIR* _parent, struct dirent *dir)
+{
+ struct __dir *parent = (struct __dir*)_parent;
+ struct stat s;
+ struct tm *tm;
+ struct dirinfo ret;
+ char path[MAX_PATH];
+
+ snprintf(path, sizeof(path), "%s/%s", parent->path, dir->d_name);
+ stat(path, &s);
+ memset(&ret, 0, sizeof(ret));
+
+ if (S_ISDIR(s.st_mode))
+ {
+ ret.attribute = ATTR_DIRECTORY;
+ }
+
+ ret.size = s.st_size;
+ tm = localtime(&(s.st_mtime));
+ ret.wrtdate = ((tm->tm_year - 80) << 9) |
+ ((tm->tm_mon + 1) << 5) |
+ tm->tm_mday;
+ ret.wrttime = (tm->tm_hour << 11) |
+ (tm->tm_min << 5) |
+ (tm->tm_sec >> 1);
+ return ret;
+}
diff --git a/firmware/target/hosted/android/lc-android.c b/firmware/target/hosted/android/lc-android.c
new file mode 100644
index 0000000000..52ab08badb
--- /dev/null
+++ b/firmware/target/hosted/android/lc-android.c
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <string.h> /* size_t */
+#include "load_code.h"
+
+/* the load_code wrappers simply wrap, nothing to do */
+void *lc_open(const char *filename, char *buf, size_t buf_size)
+{
+ return _lc_open(filename, buf, buf_size);
+}
+
+void *lc_get_header(void *handle)
+{
+ return _lc_get_header(handle);
+}
+
+void lc_close(void *handle)
+{
+ _lc_close(handle);
+}
+
diff --git a/uisimulator/common/SOURCES b/uisimulator/common/SOURCES
index a30b5abeb2..39f008b9dd 100644
--- a/uisimulator/common/SOURCES
+++ b/uisimulator/common/SOURCES
@@ -9,8 +9,10 @@ fmradio.c
backlight-sim.c
#endif
+#if !(CONFIG_PLATFORM & PLATFORM_ANDROID)
+io.c
+#endif
/* this is still needed for application since it has some stubs */
powermgmt-sim.c
-io.c
sim_tasks.c
stubs.c
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 6547421668..f630ae49c8 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -158,13 +158,18 @@ extern const char *sim_root_dir;
static int num_openfiles = 0;
-struct sim_dirent {
- unsigned char d_name[MAX_PATH];
+/* from dir.h */
+struct dirinfo {
int attribute;
long size;
+ unsigned short wrtdate;
+ unsigned short wrttime;
+};
+
+struct sim_dirent {
+ unsigned char d_name[MAX_PATH];
+ struct dirinfo info;
long startcluster;
- unsigned short wrtdate; /* Last write date */
- unsigned short wrttime; /* Last write time */
};
struct dirstruct {
@@ -329,14 +334,14 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
#define ATTR_DIRECTORY 0x10
- secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0;
- secret.size = s.st_size;
+ secret.info.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0;
+ secret.info.size = s.st_size;
tm = localtime(&(s.st_mtime));
- secret.wrtdate = ((tm->tm_year - 80) << 9) |
+ secret.info.wrtdate = ((tm->tm_year - 80) << 9) |
((tm->tm_mon + 1) << 5) |
tm->tm_mday;
- secret.wrttime = (tm->tm_hour << 11) |
+ secret.info.wrttime = (tm->tm_hour << 11) |
(tm->tm_min << 5) |
(tm->tm_sec >> 1);
return &secret;