summaryrefslogtreecommitdiffstats
path: root/firmware
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 /firmware
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
Diffstat (limited to 'firmware')
-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
18 files changed, 297 insertions, 89 deletions
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);
+}
+