summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
55#define LOGF_ENABLE 55#define LOGF_ENABLE
56#include "logf.h" 56#include "logf.h"
57 57
58#if (CONFIG_PLATFORM & PLATFORM_HOSTED) 58#if (CONFIG_PLATFORM & PLATFORM_SDL)
59
60#define PREFIX(_x_) sim_ ## _x_ 59#define PREFIX(_x_) sim_ ## _x_
60#else
61#define PREFIX(_x_) _x_
62#endif
63
64#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
61#if CONFIG_CODEC == SWCODEC 65#if CONFIG_CODEC == SWCODEC
62unsigned char codecbuf[CODEC_SIZE]; 66unsigned char codecbuf[CODEC_SIZE];
63#endif 67#endif
64void *sim_codec_load_ram(char* codecptr, int size, void **pd);
65void sim_codec_close(void *pd);
66
67#else /* !PLATFORM_HOSTED */
68
69#define PREFIX
70#define sim_codec_close(x)
71
72#endif 68#endif
73 69
74size_t codec_size; 70size_t codec_size;
@@ -110,7 +106,7 @@ struct codec_api ci = {
110#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE 106#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
111 __div0, 107 __div0,
112#endif 108#endif
113 PREFIX(sleep), 109 sleep,
114 yield, 110 yield,
115 111
116#if NUM_CORES > 1 112#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 {
159#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE 159#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
160 void (*__div0)(void); 160 void (*__div0)(void);
161#endif 161#endif
162 void (*sleep)(int ticks); 162 unsigned (*sleep)(unsigned ticks);
163 void (*yield)(void); 163 void (*yield)(void);
164 164
165#if NUM_CORES > 1 165#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;
101#define rel 13 101#define rel 13
102 102
103enum { 103enum {
104 adc, _and, asl, bcc, bcs, beq, bit, bmi, bne, bpl, brk, bvc, bvs, clc, 104 adc, _and, asl, bcc, bcs, beq, bit, bmi, bne, bpl, _brk, bvc, bvs, clc,
105 cld, cli, clv, cmp, cpx, cpy, dec, dex, dey, eor, inc, inx, iny, jmp, 105 cld, cli, clv, cmp, cpx, cpy, dec, dex, dey, eor, inc, inx, iny, jmp,
106 jsr, lda, ldx, ldy, lsr, _nop, ora, pha, php, pla, plp, rol, ror, rti, 106 jsr, lda, ldx, ldy, lsr, _nop, ora, pha, php, pla, plp, rol, ror, rti,
107 rts, sbc, sec, sed, sei, sta, stx, sty, tax, tay, tsx, txa, txs, tya, 107 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 =
204}; 204};
205 205
206static const int opcodes[256] ICONST_ATTR = { 206static const int opcodes[256] ICONST_ATTR = {
207 brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx, 207 _brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx,
208 bpl,ora,xxx,xxx,xxx,ora,asl,xxx,clc,ora,xxx,xxx,xxx,ora,asl,xxx, 208 bpl,ora,xxx,xxx,xxx,ora,asl,xxx,clc,ora,xxx,xxx,xxx,ora,asl,xxx,
209 jsr,_and,xxx,xxx,bit,_and,rol,xxx,plp,_and,rol,xxx,bit,_and,rol,xxx, 209 jsr,_and,xxx,xxx,bit,_and,rol,xxx,plp,_and,rol,xxx,bit,_and,rol,xxx,
210 bmi,_and,xxx,xxx,xxx,_and,rol,xxx,sec,_and,xxx,xxx,xxx,_and,rol,xxx, 210 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)
908 setflags(FLAG_N,bval&0x80); 908 setflags(FLAG_N,bval&0x80);
909 setflags(FLAG_V,bval&0x40); 909 setflags(FLAG_V,bval&0x40);
910 break; 910 break;
911 case brk: 911 case _brk:
912 pc=0; /* Just quit the emulation */ 912 pc=0; /* Just quit the emulation */
913 break; 913 break;
914 case clc: 914 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)
153 while((entry = readdir(dir)) != 0) /* walk directory */ 153 while((entry = readdir(dir)) != 0) /* walk directory */
154 { 154 {
155 int ext_pos; 155 int ext_pos;
156 156 struct dirinfo info = dir_get_info(dir, entry);
157 ext_pos = strlen((char *)entry->d_name) - strlen(file_thumbnail_ext); 157 ext_pos = strlen((char *)entry->d_name) - strlen(file_thumbnail_ext);
158 if (ext_pos <= 0 /* too short to carry ".talk" */ 158 if (ext_pos <= 0 /* too short to carry ".talk" */
159 || (entry->attribute & ATTR_DIRECTORY) /* no file */ 159 || (info.attribute & ATTR_DIRECTORY) /* no file */
160 || strcasecmp((char *)&entry->d_name[ext_pos], file_thumbnail_ext)) 160 || strcasecmp((char *)&entry->d_name[ext_pos], file_thumbnail_ext))
161 { /* or doesn't end with ".talk", no candidate */ 161 { /* or doesn't end with ".talk", no candidate */
162 continue; 162 continue;
@@ -284,15 +284,17 @@ int ft_load(struct tree_context* c, const char* tempdir)
284 for ( i=0; i < global_settings.max_files_in_dir; i++ ) { 284 for ( i=0; i < global_settings.max_files_in_dir; i++ ) {
285 int len; 285 int len;
286 struct dirent *entry = readdir(dir); 286 struct dirent *entry = readdir(dir);
287 struct dirinfo info;
287 struct entry* dptr = 288 struct entry* dptr =
288 (struct entry*)(c->dircache + i * sizeof(struct entry)); 289 (struct entry*)(c->dircache + i * sizeof(struct entry));
289 if (!entry) 290 if (!entry)
290 break; 291 break;
291 292
293 info = dir_get_info(dir, entry);
292 len = strlen((char *)entry->d_name); 294 len = strlen((char *)entry->d_name);
293 295
294 /* skip directories . and .. */ 296 /* skip directories . and .. */
295 if ((entry->attribute & ATTR_DIRECTORY) && 297 if ((info.attribute & ATTR_DIRECTORY) &&
296 (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) || 298 (((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) ||
297 ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) { 299 ((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) {
298 i--; 300 i--;
@@ -300,7 +302,7 @@ int ft_load(struct tree_context* c, const char* tempdir)
300 } 302 }
301 303
302 /* Skip FAT volume ID */ 304 /* Skip FAT volume ID */
303 if (entry->attribute & ATTR_VOLUME_ID) { 305 if (info.attribute & ATTR_VOLUME_ID) {
304 i--; 306 i--;
305 continue; 307 continue;
306 } 308 }
@@ -308,12 +310,12 @@ int ft_load(struct tree_context* c, const char* tempdir)
308 /* filter out dotfiles and hidden files */ 310 /* filter out dotfiles and hidden files */
309 if (*c->dirfilter != SHOW_ALL && 311 if (*c->dirfilter != SHOW_ALL &&
310 ((entry->d_name[0]=='.') || 312 ((entry->d_name[0]=='.') ||
311 (entry->attribute & ATTR_HIDDEN))) { 313 (info.attribute & ATTR_HIDDEN))) {
312 i--; 314 i--;
313 continue; 315 continue;
314 } 316 }
315 317
316 dptr->attr = entry->attribute; 318 dptr->attr = info.attribute;
317 319
318 /* check for known file types */ 320 /* check for known file types */
319 if ( !(dptr->attr & ATTR_DIRECTORY) ) 321 if ( !(dptr->attr & ATTR_DIRECTORY) )
@@ -362,8 +364,8 @@ int ft_load(struct tree_context* c, const char* tempdir)
362 } 364 }
363 dptr->name = &c->name_buffer[name_buffer_used]; 365 dptr->name = &c->name_buffer[name_buffer_used];
364 dptr->time_write = 366 dptr->time_write =
365 (long)entry->wrtdate<<16 | 367 (long)info.wrtdate<<16 |
366 (long)entry->wrttime; /* in one # */ 368 (long)info.wrttime; /* in one # */
367 strcpy(dptr->name, (char *)entry->d_name); 369 strcpy(dptr->name, (char *)entry->d_name);
368 name_buffer_used += len + 1; 370 name_buffer_used += len + 1;
369 371
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 @@
28#include "misc.h" 28#include "misc.h"
29#include "lcd.h" 29#include "lcd.h"
30#include "file.h" 30#include "file.h"
31#include "filefuncs.h"
31#ifndef __PCTOOL__ 32#ifndef __PCTOOL__
32#include "lang.h" 33#include "lang.h"
33#include "dir.h" 34#include "dir.h"
@@ -708,11 +709,12 @@ void check_bootfile(bool do_rolo)
708 { 709 {
709 if(!strcasecmp(entry->d_name, BOOTFILE)) 710 if(!strcasecmp(entry->d_name, BOOTFILE))
710 { 711 {
712 struct dirinfo info = dir_get_info(dir, entry);
711 /* found the bootfile */ 713 /* found the bootfile */
712 if(wrtdate && do_rolo) 714 if(wrtdate && do_rolo)
713 { 715 {
714 if((entry->wrtdate != wrtdate) || 716 if((info.wrtdate != wrtdate) ||
715 (entry->wrttime != wrttime)) 717 (info.wrttime != wrttime))
716 { 718 {
717 static const char *lines[] = { ID2P(LANG_BOOT_CHANGED), 719 static const char *lines[] = { ID2P(LANG_BOOT_CHANGED),
718 ID2P(LANG_REBOOT_NOW) }; 720 ID2P(LANG_REBOOT_NOW) };
@@ -722,8 +724,8 @@ void check_bootfile(bool do_rolo)
722 rolo_load(BOOTDIR "/" BOOTFILE); 724 rolo_load(BOOTDIR "/" BOOTFILE);
723 } 725 }
724 } 726 }
725 wrtdate = entry->wrtdate; 727 wrtdate = info.wrtdate;
726 wrttime = entry->wrttime; 728 wrttime = info.wrttime;
727 } 729 }
728 } 730 }
729 closedir(dir); 731 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 @@
26 26
27#include "debug.h" 27#include "debug.h"
28#include "lcd.h" 28#include "lcd.h"
29#include "dir.h"
30#include "file.h" 29#include "file.h"
31#include "audio.h" 30#include "audio.h"
32#include "menu.h" 31#include "menu.h"
@@ -63,6 +62,7 @@
63#include "statusbar-skinned.h" 62#include "statusbar-skinned.h"
64#include "pitchscreen.h" 63#include "pitchscreen.h"
65#include "viewport.h" 64#include "viewport.h"
65#include "filefuncs.h"
66 66
67static int context; 67static int context;
68static char* selected_file = NULL; 68static char* selected_file = NULL;
@@ -484,14 +484,14 @@ static int remove_dir(char* dirname, int len)
484 entry = readdir(dir); 484 entry = readdir(dir);
485 if (!entry) 485 if (!entry)
486 break; 486 break;
487 487 struct dirinfo info = dir_get_info(dir, entry);
488 dirname[dirlen] ='\0'; 488 dirname[dirlen] ='\0';
489 /* inform the user which dir we're deleting */ 489 /* inform the user which dir we're deleting */
490 splash(0, dirname); 490 splash(0, dirname);
491 491
492 /* append name to current directory */ 492 /* append name to current directory */
493 snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name); 493 snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name);
494 if (entry->attribute & ATTR_DIRECTORY) 494 if (info.attribute & ATTR_DIRECTORY)
495 { /* remove a subdirectory */ 495 { /* remove a subdirectory */
496 if (!strcmp((char *)entry->d_name, ".") || 496 if (!strcmp((char *)entry->d_name, ".") ||
497 !strcmp((char *)entry->d_name, "..")) 497 !strcmp((char *)entry->d_name, ".."))
@@ -783,6 +783,7 @@ static bool clipboard_pastedirectory(char *src, int srclen, char *target,
783 if (!entry) 783 if (!entry)
784 break; 784 break;
785 785
786 struct dirinfo info = dir_get_info(srcdir, entry);
786 /* append name to current directory */ 787 /* append name to current directory */
787 snprintf(src+srcdirlen, srclen-srcdirlen, "/%s", entry->d_name); 788 snprintf(src+srcdirlen, srclen-srcdirlen, "/%s", entry->d_name);
788 snprintf(target+targetdirlen, targetlen-targetdirlen, "/%s", 789 snprintf(target+targetdirlen, targetlen-targetdirlen, "/%s",
@@ -790,7 +791,7 @@ static bool clipboard_pastedirectory(char *src, int srclen, char *target,
790 791
791 DEBUGF("Copy %s to %s\n", src, target); 792 DEBUGF("Copy %s to %s\n", src, target);
792 793
793 if (entry->attribute & ATTR_DIRECTORY) 794 if (info.attribute & ATTR_DIRECTORY)
794 { /* copy/move a subdirectory */ 795 { /* copy/move a subdirectory */
795 if (!strcmp((char *)entry->d_name, ".") || 796 if (!strcmp((char *)entry->d_name, ".") ||
796 !strcmp((char *)entry->d_name, "..")) 797 !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 @@
59#include "usbstack/usb_hid.h" 59#include "usbstack/usb_hid.h"
60#endif 60#endif
61 61
62#if (CONFIG_PLATFORM & PLATFORM_HOSTED) 62#if (CONFIG_PLATFORM & PLATFORM_SDL)
63#define PREFIX(_x_) sim_ ## _x_ 63#define PREFIX(_x_) sim_ ## _x_
64#else 64#else
65#define PREFIX 65#define PREFIX
@@ -349,7 +349,7 @@ static const struct plugin_api rockbox_api = {
349#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE 349#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
350 __div0, 350 __div0,
351#endif 351#endif
352 PREFIX(sleep), 352 sleep,
353 yield, 353 yield,
354 &current_tick, 354 &current_tick,
355 default_event_handler, 355 default_event_handler,
@@ -529,7 +529,7 @@ static const struct plugin_api rockbox_api = {
529 playlist_insert_track, 529 playlist_insert_track,
530 playlist_insert_directory, 530 playlist_insert_directory,
531 playlist_shuffle, 531 playlist_shuffle,
532 PREFIX(audio_play), 532 audio_play,
533 audio_stop, 533 audio_stop,
534 audio_pause, 534 audio_pause,
535 audio_resume, 535 audio_resume,
@@ -722,6 +722,7 @@ static const struct plugin_api rockbox_api = {
722 722
723 /* new stuff at the end, sort into place next time 723 /* new stuff at the end, sort into place next time
724 the API gets incompatible */ 724 the API gets incompatible */
725 dir_get_info,
725}; 726};
726 727
727int plugin_load(const char* plugin, const void* parameter) 728int plugin_load(const char* plugin, const void* parameter)
@@ -940,11 +941,11 @@ static int open_wrapper(const char* pathname, int flags, ...)
940 { 941 {
941 va_list ap; 942 va_list ap;
942 va_start(ap, flags); 943 va_start(ap, flags);
943 fd = sim_open(pathname, flags, va_arg(ap, unsigned int)); 944 fd = open(pathname, flags, va_arg(ap, unsigned int));
944 va_end(ap); 945 va_end(ap);
945 } 946 }
946 else 947 else
947 fd = sim_open(pathname, flags); 948 fd = open(pathname, flags);
948#else 949#else
949 fd = file_open(pathname,flags); 950 fd = file_open(pathname,flags);
950#endif 951#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 {
459#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE 459#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
460 void (*__div0)(void); 460 void (*__div0)(void);
461#endif 461#endif
462 void (*sleep)(int ticks); 462 unsigned (*sleep)(unsigned ticks);
463 void (*yield)(void); 463 void (*yield)(void);
464 volatile long* current_tick; 464 volatile long* current_tick;
465 long (*default_event_handler)(long event); 465 long (*default_event_handler)(long event);
@@ -894,6 +894,7 @@ struct plugin_api {
894 894
895 /* new stuff at the end, sort into place next time 895 /* new stuff at the end, sort into place next time
896 the API gets incompatible */ 896 the API gets incompatible */
897 struct dirinfo (*dir_get_info)(struct DIR* parent, struct dirent *entry);
897}; 898};
898 899
899/* plugin header */ 900/* 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)
244 /* silent error */ 244 /* silent error */
245 continue; 245 continue;
246 246
247 if (entry->attribute & ATTR_DIRECTORY) 247
248 struct dirinfo info = rb->dir_get_info(dir, entry);
249 if (info.attribute & ATTR_DIRECTORY)
248 { 250 {
249 /* dir ignore "." and ".." */ 251 /* dir ignore "." and ".." */
250 if ((rb->strcmp(entry->d_name, ".") != 0) && \ 252 if ((rb->strcmp(entry->d_name, ".") != 0) && \
@@ -297,6 +299,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
297 while((status == TIDY_RETURN_OK) && ((entry = rb->readdir(dir)) != 0)) 299 while((status == TIDY_RETURN_OK) && ((entry = rb->readdir(dir)) != 0))
298 /* walk directory */ 300 /* walk directory */
299 { 301 {
302 struct dirinfo info = rb->dir_get_info(dir, entry);
300 /* check for user input and usb connect */ 303 /* check for user input and usb connect */
301 button = rb->get_action(CONTEXT_STD, TIMEOUT_NOBLOCK); 304 button = rb->get_action(CONTEXT_STD, TIMEOUT_NOBLOCK);
302 if (button == ACTION_STD_CANCEL) 305 if (button == ACTION_STD_CANCEL)
@@ -312,7 +315,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
312 315
313 rb->yield(); 316 rb->yield();
314 317
315 if (entry->attribute & ATTR_DIRECTORY) 318 if (info.attribute & ATTR_DIRECTORY)
316 { 319 {
317 /* directory ignore "." and ".." */ 320 /* directory ignore "." and ".." */
318 if ((rb->strcmp(entry->d_name, ".") != 0) && \ 321 if ((rb->strcmp(entry->d_name, ".") != 0) && \
@@ -326,7 +329,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
326 /* silent error */ 329 /* silent error */
327 continue; 330 continue;
328 331
329 if (tidy_remove_item(entry->d_name, entry->attribute)) 332 if (tidy_remove_item(entry->d_name, info.attribute))
330 { 333 {
331 /* delete dir */ 334 /* delete dir */
332 tidy_removedir(path, path_length); 335 tidy_removedir(path, path_length);
@@ -347,7 +350,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
347 { 350 {
348 /* file */ 351 /* file */
349 del = 0; 352 del = 0;
350 if (tidy_remove_item(entry->d_name, entry->attribute)) 353 if (tidy_remove_item(entry->d_name, info.attribute))
351 { 354 {
352 /* get absolute path */ 355 /* get absolute path */
353 /* returns an error if path is too long */ 356 /* returns an error if path is too long */
diff --git a/apps/plugins/lua/luadir.c b/apps/plugins/lua/luadir.c
index 730c40ce22..c8c21d2c65 100644
--- a/apps/plugins/lua/luadir.c
+++ b/apps/plugins/lua/luadir.c
@@ -56,8 +56,9 @@ static int dir_iter (lua_State *L) {
56 luaL_argcheck (L, !d->closed, 1, "closed directory"); 56 luaL_argcheck (L, !d->closed, 1, "closed directory");
57 57
58 if ((entry = rb->readdir (d->dir)) != NULL) { 58 if ((entry = rb->readdir (d->dir)) != NULL) {
59 struct dirinfo info = rb->dir_get_info(d->dir, entry);
59 lua_pushstring (L, entry->d_name); 60 lua_pushstring (L, entry->d_name);
60 lua_pushboolean (L, entry->attribute & ATTR_DIRECTORY); 61 lua_pushboolean (L, info.attribute & ATTR_DIRECTORY);
61 return 2; 62 return 2;
62 } else { 63 } else {
63 /* no more entries => close directory */ 64 /* no more entries => close directory */
diff --git a/apps/plugins/md5sum.c b/apps/plugins/md5sum.c
index fe1c65efb0..c993018852 100644
--- a/apps/plugins/md5sum.c
+++ b/apps/plugins/md5sum.c
@@ -95,7 +95,9 @@ static void hash_dir( int out, const char *path )
95 char childpath[MAX_PATH]; 95 char childpath[MAX_PATH];
96 rb->snprintf( childpath, MAX_PATH, "%s/%s", 96 rb->snprintf( childpath, MAX_PATH, "%s/%s",
97 rb->strcmp( path, "/" ) ? path : "", entry->d_name ); 97 rb->strcmp( path, "/" ) ? path : "", entry->d_name );
98 if( entry->attribute & ATTR_DIRECTORY ) 98
99 struct dirinfo info = rb->dir_get_info(dir, entry);
100 if (info.attribute & ATTR_DIRECTORY)
99 { 101 {
100 if( rb->strcmp( entry->d_name, "." ) 102 if( rb->strcmp( entry->d_name, "." )
101 && rb->strcmp( entry->d_name, ".." ) ) 103 && rb->strcmp( entry->d_name, ".." ) )
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index d6692bc893..e127a2908e 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -69,22 +69,23 @@ static bool file_properties(char* selected_file)
69 { 69 {
70 while(0 != (entry = rb->readdir(dir))) 70 while(0 != (entry = rb->readdir(dir)))
71 { 71 {
72 struct dirinfo info = rb->dir_get_info(dir, entry);
72 if(!rb->strcmp(entry->d_name, selected_file+dirlen)) 73 if(!rb->strcmp(entry->d_name, selected_file+dirlen))
73 { 74 {
74 unsigned log; 75 unsigned log;
75 rb->snprintf(str_dirname, sizeof str_dirname, "Path: %s", tstr); 76 rb->snprintf(str_dirname, sizeof str_dirname, "Path: %s", tstr);
76 rb->snprintf(str_filename, sizeof str_filename, "Name: %s", 77 rb->snprintf(str_filename, sizeof str_filename, "Name: %s",
77 selected_file+dirlen); 78 selected_file+dirlen);
78 log = human_size_log(entry->size); 79 log = human_size_log(info.size);
79 rb->snprintf(str_size, sizeof str_size, "Size: %ld %cB", 80 rb->snprintf(str_size, sizeof str_size, "Size: %ld %cB",
80 entry->size >> (log*10), human_size_prefix[log]); 81 info.size >> (log*10), human_size_prefix[log]);
81 rb->snprintf(str_date, sizeof str_date, "Date: %04d/%02d/%02d", 82 rb->snprintf(str_date, sizeof str_date, "Date: %04d/%02d/%02d",
82 ((entry->wrtdate >> 9 ) & 0x7F) + 1980, /* year */ 83 ((info.wrtdate >> 9 ) & 0x7F) + 1980, /* year */
83 ((entry->wrtdate >> 5 ) & 0x0F), /* month */ 84 ((info.wrtdate >> 5 ) & 0x0F), /* month */
84 ((entry->wrtdate ) & 0x1F)); /* day */ 85 ((info.wrtdate ) & 0x1F)); /* day */
85 rb->snprintf(str_time, sizeof str_time, "Time: %02d:%02d", 86 rb->snprintf(str_time, sizeof str_time, "Time: %02d:%02d",
86 ((entry->wrttime >> 11) & 0x1F), /* hour */ 87 ((info.wrttime >> 11) & 0x1F), /* hour */
87 ((entry->wrttime >> 5 ) & 0x3F)); /* minutes */ 88 ((info.wrttime >> 5 ) & 0x3F)); /* minutes */
88 89
89 num_properties = 5; 90 num_properties = 5;
90 91
@@ -158,11 +159,12 @@ static bool _dir_properties(DPS* dps)
158 /* walk through the directory content */ 159 /* walk through the directory content */
159 while(result && (0 != (entry = rb->readdir(dir)))) 160 while(result && (0 != (entry = rb->readdir(dir))))
160 { 161 {
162 struct dirinfo info = rb->dir_get_info(dir, entry);
161 /* append name to current directory */ 163 /* append name to current directory */
162 rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s", 164 rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s",
163 entry->d_name); 165 entry->d_name);
164 166
165 if (entry->attribute & ATTR_DIRECTORY) 167 if (info.attribute & ATTR_DIRECTORY)
166 { 168 {
167 unsigned log; 169 unsigned log;
168 170
@@ -188,7 +190,7 @@ static bool _dir_properties(DPS* dps)
188 else 190 else
189 { 191 {
190 dps->fc++; /* new file */ 192 dps->fc++; /* new file */
191 dps->bc += entry->size; 193 dps->bc += info.size;
192 } 194 }
193 if(ACTION_STD_CANCEL == rb->get_action(CONTEXT_STD,TIMEOUT_NOBLOCK)) 195 if(ACTION_STD_CANCEL == rb->get_action(CONTEXT_STD,TIMEOUT_NOBLOCK))
194 result = false; 196 result = false;
@@ -290,7 +292,8 @@ enum plugin_status plugin_start(const void* parameter)
290 { 292 {
291 if(!rb->strcmp(entry->d_name, file+dirlen)) 293 if(!rb->strcmp(entry->d_name, file+dirlen))
292 { 294 {
293 its_a_dir = entry->attribute & ATTR_DIRECTORY ? true : false; 295 struct dirinfo info = rb->dir_get_info(dir, entry);
296 its_a_dir = info.attribute & ATTR_DIRECTORY ? true : false;
294 found = true; 297 found = true;
295 break; 298 break;
296 } 299 }
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index 55d9bf99ab..eca33dc08a 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -98,7 +98,8 @@ void traversedir(char* location, char* name)
98 98
99 if (check) 99 if (check)
100 { 100 {
101 if (entry->attribute & ATTR_DIRECTORY) { 101 struct dirinfo info = rb->dir_get_info(dir, entry);
102 if (info.attribute & ATTR_DIRECTORY) {
102 char *start; 103 char *start;
103 dirs_count++; 104 dirs_count++;
104 rb->snprintf(path,MAX_PATH,"%s/%s",fullpath,entry->d_name); 105 rb->snprintf(path,MAX_PATH,"%s/%s",fullpath,entry->d_name);
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index ecf335d3f0..6a70a47ec4 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -178,7 +178,8 @@ void traversedir(char* location, char* name)
178 /* Skip .. and . */ 178 /* Skip .. and . */
179 if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, "..")) 179 if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, ".."))
180 { 180 {
181 if (entry->attribute & ATTR_DIRECTORY) { 181 struct dirinfo info = rb->dir_get_info(dir, entry);
182 if (info.attribute & ATTR_DIRECTORY) {
182 traversedir(fullpath, entry->d_name); 183 traversedir(fullpath, entry->d_name);
183 dirs++; 184 dirs++;
184 } 185 }
diff --git a/apps/plugins/theme_remove.c b/apps/plugins/theme_remove.c
index d679338ff8..674342a920 100644
--- a/apps/plugins/theme_remove.c
+++ b/apps/plugins/theme_remove.c
@@ -236,7 +236,8 @@ static int remove_dir(char* dirname, int len)
236 236
237 /* append name to current directory */ 237 /* append name to current directory */
238 rb->snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name); 238 rb->snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name);
239 if (entry->attribute & ATTR_DIRECTORY) 239 struct dirinfo info = rb->dir_get_info(dir, entry);
240 if (info.attribute & ATTR_DIRECTORY)
240 { 241 {
241 /* remove a subdirectory */ 242 /* remove a subdirectory */
242 if (!rb->strcmp((char *)entry->d_name, ".") || 243 if (!rb->strcmp((char *)entry->d_name, ".") ||
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)
4222 success = true; 4222 success = true;
4223 break ; 4223 break ;
4224 } 4224 }
4225
4226 struct dirinfo info = dir_get_info(dir, entry);
4225 4227
4226 if (!strcmp((char *)entry->d_name, ".") || 4228 if (!strcmp((char *)entry->d_name, ".") ||
4227 !strcmp((char *)entry->d_name, "..")) 4229 !strcmp((char *)entry->d_name, ".."))
@@ -4234,14 +4236,14 @@ static bool check_dir(const char *dirname, int add_files)
4234 entry->d_name); 4236 entry->d_name);
4235 4237
4236 processed_dir_count++; 4238 processed_dir_count++;
4237 if (entry->attribute & ATTR_DIRECTORY) 4239 if (info.attribute & ATTR_DIRECTORY)
4238 check_dir(curpath, add_files); 4240 check_dir(curpath, add_files);
4239 else if (add_files) 4241 else if (add_files)
4240 { 4242 {
4241 tc_stat.curentry = curpath; 4243 tc_stat.curentry = curpath;
4242 4244
4243 /* Add a new entry to the temporary db file. */ 4245 /* Add a new entry to the temporary db file. */
4244 add_tagcache(curpath, (entry->wrtdate << 16) | entry->wrttime 4246 add_tagcache(curpath, (info.wrtdate << 16) | info.wrttime
4245#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) 4247#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
4246 , dir->internal_entry 4248 , dir->internal_entry
4247#endif 4249#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 @@
51#include "audio.h" 51#include "audio.h"
52#include "appevents.h" 52#include "appevents.h"
53#include "storage.h" 53#include "storage.h"
54#include "dir_uncached.h" 54#include "dir.h"
55 55
56#define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" 56#define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config"
57 57
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
1703 1703
1704 1704
1705#if (CONFIG_PLATFORM & PLATFORM_ANDROID) 1705#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
1706target/hosted/android/fs-android.c
1706target/hosted/android/lcd-android.c 1707target/hosted/android/lcd-android.c
1708target/hosted/android/lc-android.c
1707target/hosted/android/button-android.c 1709target/hosted/android/button-android.c
1708target/hosted/android/kernel-android.c 1710target/hosted/android/kernel-android.c
1709target/hosted/android/pcm-android.c 1711target/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)
171 if (fat_ismounted(dir->volumecounter)) 171 if (fat_ismounted(dir->volumecounter))
172 { 172 {
173 memset(theent, 0, sizeof(*theent)); 173 memset(theent, 0, sizeof(*theent));
174 theent->attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME; 174 theent->info.attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME;
175 snprintf(theent->d_name, sizeof(theent->d_name), 175 snprintf(theent->d_name, sizeof(theent->d_name),
176 VOL_NAMES, dir->volumecounter); 176 VOL_NAMES, dir->volumecounter);
177 return theent; 177 return theent;
@@ -187,11 +187,11 @@ struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir)
187 return NULL; 187 return NULL;
188 188
189 strlcpy(theent->d_name, entry.name, sizeof(theent->d_name)); 189 strlcpy(theent->d_name, entry.name, sizeof(theent->d_name));
190 theent->attribute = entry.attr; 190 theent->info.attribute = entry.attr;
191 theent->size = entry.filesize; 191 theent->info.wrtdate = entry.wrtdate;
192 theent->info.wrttime = entry.wrttime;
193 theent->info.size = entry.filesize;
192 theent->startcluster = entry.firstcluster; 194 theent->startcluster = entry.firstcluster;
193 theent->wrtdate = entry.wrtdate;
194 theent->wrttime = entry.wrttime;
195 195
196 return theent; 196 return theent;
197} 197}
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
237 !strcmp("..", sab.direntry->name)) 237 !strcmp("..", sab.direntry->name))
238 continue; 238 continue;
239 239
240 ce->attribute = sab.direntry->attr;
241 ce->name_len = strlen(sab.direntry->name) + 1; 240 ce->name_len = strlen(sab.direntry->name) + 1;
242 ce->d_name = ((char *)dircache_root + dircache_size); 241 ce->d_name = ((char *)dircache_root + dircache_size);
243 ce->startcluster = sab.direntry->firstcluster; 242 ce->startcluster = sab.direntry->firstcluster;
244 ce->size = sab.direntry->filesize; 243 ce->info.size = sab.direntry->filesize;
245 ce->wrtdate = sab.direntry->wrtdate; 244 ce->info.attribute = sab.direntry->attr;
246 ce->wrttime = sab.direntry->wrttime; 245 ce->info.wrtdate = sab.direntry->wrtdate;
246 ce->info.wrttime = sab.direntry->wrttime;
247 memcpy(ce->d_name, sab.direntry->name, ce->name_len); 247 memcpy(ce->d_name, sab.direntry->name, ce->name_len);
248 248
249 dircache_size += ce->name_len; 249 dircache_size += ce->name_len;
250 entry_count++; 250 entry_count++;
251 251
252 if(ce->attribute & FAT_ATTR_DIRECTORY) 252 if(ce->info.attribute & FAT_ATTR_DIRECTORY)
253 dircache_gen_down(ce); 253 dircache_gen_down(ce);
254 254
255 ce = dircache_gen_next(ce); 255 ce = dircache_gen_next(ce);
@@ -269,18 +269,18 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
269 /* add "." and ".." */ 269 /* add "." and ".." */
270 ce->d_name = "."; 270 ce->d_name = ".";
271 ce->name_len = 2; 271 ce->name_len = 2;
272 ce->attribute = FAT_ATTR_DIRECTORY; 272 ce->info.attribute = FAT_ATTR_DIRECTORY;
273 ce->startcluster = startcluster; 273 ce->startcluster = startcluster;
274 ce->size = 0; 274 ce->info.size = 0;
275 ce->down = first_ce; 275 ce->down = first_ce;
276 276
277 ce = dircache_gen_next(ce); 277 ce = dircache_gen_next(ce);
278 278
279 ce->d_name = ".."; 279 ce->d_name = "..";
280 ce->name_len = 3; 280 ce->name_len = 3;
281 ce->attribute = FAT_ATTR_DIRECTORY; 281 ce->info.attribute = FAT_ATTR_DIRECTORY;
282 ce->startcluster = (first_ce->up ? first_ce->up->startcluster : 0); 282 ce->startcluster = (first_ce->up ? first_ce->up->startcluster : 0);
283 ce->size = 0; 283 ce->info.size = 0;
284 ce->down = first_ce->up; 284 ce->down = first_ce->up;
285 285
286 /* second pass: recurse ! */ 286 /* second pass: recurse ! */
@@ -311,8 +311,8 @@ static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce
311 snprintf(ce->d_name, VOL_ENUM_POS + 3, VOL_NAMES, volume); 311 snprintf(ce->d_name, VOL_ENUM_POS + 3, VOL_NAMES, volume);
312 ce->name_len = VOL_ENUM_POS + 3; 312 ce->name_len = VOL_ENUM_POS + 3;
313 dircache_size += ce->name_len; 313 dircache_size += ce->name_len;
314 ce->attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME; 314 ce->info.attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME;
315 ce->size = 0; 315 ce->info.size = 0;
316 append_position = dircache_gen_next(ce); 316 append_position = dircache_gen_next(ce);
317 ce = dircache_gen_down(ce); 317 ce = dircache_gen_down(ce);
318 } 318 }
@@ -347,18 +347,15 @@ static int sab_process_dir(struct dircache_entry *ce)
347 !strcmp("..", entry->d_name)) 347 !strcmp("..", entry->d_name))
348 continue; 348 continue;
349 349
350 ce->attribute = entry->attribute;
351 ce->name_len = strlen(entry->d_name) + 1; 350 ce->name_len = strlen(entry->d_name) + 1;
352 ce->d_name = ((char *)dircache_root + dircache_size); 351 ce->d_name = ((char *)dircache_root + dircache_size);
353 ce->size = entry->size; 352 ce->info = entry->info;
354 ce->wrtdate = entry->wrtdate;
355 ce->wrttime = entry->wrttime;
356 memcpy(ce->d_name, entry->d_name, ce->name_len); 353 memcpy(ce->d_name, entry->d_name, ce->name_len);
357 354
358 dircache_size += ce->name_len; 355 dircache_size += ce->name_len;
359 entry_count++; 356 entry_count++;
360 357
361 if(entry->attribute & ATTR_DIRECTORY) 358 if(entry->info.attribute & ATTR_DIRECTORY)
362 { 359 {
363 dircache_gen_down(ce); 360 dircache_gen_down(ce);
364 if(ce->down == NULL) 361 if(ce->down == NULL)
@@ -400,16 +397,16 @@ static int sab_process_dir(struct dircache_entry *ce)
400 /* add "." and ".." */ 397 /* add "." and ".." */
401 ce->d_name = "."; 398 ce->d_name = ".";
402 ce->name_len = 2; 399 ce->name_len = 2;
403 ce->attribute = ATTR_DIRECTORY; 400 ce->info.attribute = ATTR_DIRECTORY;
404 ce->size = 0; 401 ce->info.size = 0;
405 ce->down = first_ce; 402 ce->down = first_ce;
406 403
407 ce = dircache_gen_next(ce); 404 ce = dircache_gen_next(ce);
408 405
409 ce->d_name = ".."; 406 ce->d_name = "..";
410 ce->name_len = 3; 407 ce->name_len = 3;
411 ce->attribute = ATTR_DIRECTORY; 408 ce->info.attribute = ATTR_DIRECTORY;
412 ce->size = 0; 409 ce->info.size = 0;
413 ce->down = first_ce->up; 410 ce->down = first_ce->up;
414 411
415 closedir_uncached(dir); 412 closedir_uncached(dir);
@@ -1022,13 +1019,11 @@ static struct dircache_entry* dircache_new_entry(const char *path, int attribute
1022 return NULL; 1019 return NULL;
1023 } 1020 }
1024 1021
1025 entry->attribute = attribute;
1026 entry->name_len = MIN(254, strlen(new)) + 1; 1022 entry->name_len = MIN(254, strlen(new)) + 1;
1027 entry->d_name = ((char *)dircache_root+dircache_size); 1023 entry->d_name = ((char *)dircache_root+dircache_size);
1028 entry->startcluster = 0; 1024 entry->startcluster = 0;
1029 entry->wrtdate = 0; 1025 memset(&entry->info, 0, sizeof(entry->info));
1030 entry->wrttime = 0; 1026 entry->info.attribute = attribute;
1031 entry->size = 0;
1032 memcpy(entry->d_name, new, entry->name_len); 1027 memcpy(entry->d_name, new, entry->name_len);
1033 dircache_size += entry->name_len; 1028 dircache_size += entry->name_len;
1034 1029
@@ -1086,7 +1081,7 @@ void dircache_update_filesize(int fd, long newsize, long startcluster)
1086 return ; 1081 return ;
1087 } 1082 }
1088 1083
1089 fd_bindings[fd]->size = newsize; 1084 fd_bindings[fd]->info.size = newsize;
1090 fd_bindings[fd]->startcluster = startcluster; 1085 fd_bindings[fd]->startcluster = startcluster;
1091} 1086}
1092void dircache_update_filetime(int fd) 1087void dircache_update_filetime(int fd)
@@ -1106,12 +1101,12 @@ void dircache_update_filetime(int fd)
1106 return ; 1101 return ;
1107 } 1102 }
1108 year = now->tm_year+1900-1980; 1103 year = now->tm_year+1900-1980;
1109 fd_bindings[fd]->wrtdate = (((year)&0x7f)<<9) | 1104 fd_bindings[fd]->info.wrtdate = (((year)&0x7f)<<9) |
1110 (((now->tm_mon+1)&0xf)<<5) | 1105 (((now->tm_mon+1)&0xf)<<5) |
1111 (((now->tm_mday)&0x1f)); 1106 (((now->tm_mday)&0x1f));
1112 fd_bindings[fd]->wrttime = (((now->tm_hour)&0x1f)<<11) | 1107 fd_bindings[fd]->info.wrttime = (((now->tm_hour)&0x1f)<<11) |
1113 (((now->tm_min)&0x3f)<<5) | 1108 (((now->tm_min)&0x3f)<<5) |
1114 (((now->tm_sec/2)&0x1f)); 1109 (((now->tm_sec/2)&0x1f));
1115#endif 1110#endif
1116} 1111}
1117 1112
@@ -1211,7 +1206,7 @@ void dircache_rename(const char *oldpath, const char *newpath)
1211 newpath = absolute_path; 1206 newpath = absolute_path;
1212 } 1207 }
1213 1208
1214 newentry = dircache_new_entry(newpath, entry->attribute); 1209 newentry = dircache_new_entry(newpath, entry->info.attribute);
1215 if (newentry == NULL) 1210 if (newentry == NULL)
1216 { 1211 {
1217 dircache_initialized = false; 1212 dircache_initialized = false;
@@ -1219,10 +1214,10 @@ void dircache_rename(const char *oldpath, const char *newpath)
1219 } 1214 }
1220 1215
1221 newentry->down = oldentry.down; 1216 newentry->down = oldentry.down;
1222 newentry->size = oldentry.size;
1223 newentry->startcluster = oldentry.startcluster; 1217 newentry->startcluster = oldentry.startcluster;
1224 newentry->wrttime = oldentry.wrttime; 1218 newentry->info.size = oldentry.info.size;
1225 newentry->wrtdate = oldentry.wrtdate; 1219 newentry->info.wrtdate = oldentry.info.wrtdate;
1220 newentry->info.wrttime = oldentry.info.wrttime;
1226} 1221}
1227 1222
1228void dircache_add_file(const char *path, long startcluster) 1223void dircache_add_file(const char *path, long startcluster)
@@ -1279,7 +1274,7 @@ DIR_CACHED* opendir_cached(const char* name)
1279 { 1274 {
1280 pdir->regulardir = NULL; 1275 pdir->regulardir = NULL;
1281 pdir->internal_entry = dircache_get_entry(name, true); 1276 pdir->internal_entry = dircache_get_entry(name, true);
1282 pdir->theent.attribute = -1; /* used to make readdir_cached aware of the first call */ 1277 pdir->theent.info.attribute = -1; /* used to make readdir_cached aware of the first call */
1283 } 1278 }
1284 1279
1285 if (pdir->internal_entry == NULL && pdir->regulardir == NULL) 1280 if (pdir->internal_entry == NULL && pdir->regulardir == NULL)
@@ -1306,11 +1301,8 @@ struct dirent_cached* readdir_cached(DIR_CACHED* dir)
1306 return NULL; 1301 return NULL;
1307 1302
1308 strlcpy(dir->theent.d_name, regentry->d_name, MAX_PATH); 1303 strlcpy(dir->theent.d_name, regentry->d_name, MAX_PATH);
1309 dir->theent.size = regentry->size;
1310 dir->theent.startcluster = regentry->startcluster; 1304 dir->theent.startcluster = regentry->startcluster;
1311 dir->theent.attribute = regentry->attribute; 1305 dir->theent.info = regentry->info;
1312 dir->theent.wrttime = regentry->wrttime;
1313 dir->theent.wrtdate = regentry->wrtdate;
1314 1306
1315 return &dir->theent; 1307 return &dir->theent;
1316 } 1308 }
@@ -1318,7 +1310,7 @@ struct dirent_cached* readdir_cached(DIR_CACHED* dir)
1318 /* if theent.attribute=-1 then this is the first call */ 1310 /* if theent.attribute=-1 then this is the first call */
1319 /* otherwise, this is is not so we first take the entry's ->next */ 1311 /* otherwise, this is is not so we first take the entry's ->next */
1320 /* NOTE: normal file can't have attribute=-1 */ 1312 /* NOTE: normal file can't have attribute=-1 */
1321 if(dir->theent.attribute != -1) 1313 if(dir->theent.info.attribute != -1)
1322 ce = ce->next; 1314 ce = ce->next;
1323 /* skip unused entries */ 1315 /* skip unused entries */
1324 while(ce != NULL && ce->name_len == 0) 1316 while(ce != NULL && ce->name_len == 0)
@@ -1330,11 +1322,8 @@ struct dirent_cached* readdir_cached(DIR_CACHED* dir)
1330 strlcpy(dir->theent.d_name, ce->d_name, MAX_PATH); 1322 strlcpy(dir->theent.d_name, ce->d_name, MAX_PATH);
1331 /* Can't do `dir->theent = *ce` 1323 /* Can't do `dir->theent = *ce`
1332 because that modifies the d_name pointer. */ 1324 because that modifies the d_name pointer. */
1333 dir->theent.size = ce->size;
1334 dir->theent.startcluster = ce->startcluster; 1325 dir->theent.startcluster = ce->startcluster;
1335 dir->theent.attribute = ce->attribute; 1326 dir->theent.info = ce->info;
1336 dir->theent.wrttime = ce->wrttime;
1337 dir->theent.wrtdate = ce->wrtdate;
1338 dir->internal_entry = ce; 1327 dir->internal_entry = ce;
1339 1328
1340 //logf("-> %s", ce->name); 1329 //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)
124 ce->startcluster, 124 ce->startcluster,
125 &(file->fatfile), 125 &(file->fatfile),
126 NULL); 126 NULL);
127 file->size = ce->size; 127 file->size = ce->info.size;
128 file->attr = ce->attribute; 128 file->attr = ce->info.attribute;
129 file->cacheoffset = -1; 129 file->cacheoffset = -1;
130 file->fileoffset = 0; 130 file->fileoffset = 0;
131 131
@@ -169,8 +169,8 @@ static int open_internal(const char* pathname, int flags, bool use_cache)
169 entry->startcluster, 169 entry->startcluster,
170 &(file->fatfile), 170 &(file->fatfile),
171 &(dir->fatdir)); 171 &(dir->fatdir));
172 file->size = file->trunc ? 0 : entry->size; 172 file->size = file->trunc ? 0 : entry->info.size;
173 file->attr = entry->attribute; 173 file->attr = entry->info.attribute;
174 break; 174 break;
175 } 175 }
176 } 176 }
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 @@
23#include "stdlib.h" 23#include "stdlib.h"
24#include "string.h" 24#include "string.h"
25#include "debug.h" 25#include "debug.h"
26#include "file.h"
26#include "filefuncs.h" 27#include "filefuncs.h"
27 28
28#ifdef HAVE_MULTIVOLUME 29#ifdef HAVE_MULTIVOLUME
@@ -87,4 +88,12 @@ bool dir_exists(const char *path)
87 closedir(d); 88 closedir(d);
88 return true; 89 return true;
89} 90}
91
92#if !(CONFIG_PLATFORM & PLATFORM_ANDROID)
93struct dirinfo dir_get_info(struct DIR* parent, struct dirent *entry)
94{
95 (void)parent;
96 return entry->info;
97}
98#endif
90#endif /* __PCTOOL__ */ 99#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 @@
35#endif /* HAVE_RECORDING */ 35#endif /* HAVE_RECORDING */
36#endif /* CONFIG_CODEC == SWCODEC */ 36#endif /* CONFIG_CODEC == SWCODEC */
37 37
38
39#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
40#define audio_play(x) sim_audio_play(x)
41#endif
42
43#define AUDIO_STATUS_PLAY 0x0001 38#define AUDIO_STATUS_PLAY 0x0001
44#define AUDIO_STATUS_PAUSE 0x0002 39#define AUDIO_STATUS_PAUSE 0x0002
45#define AUDIO_STATUS_RECORD 0x0004 40#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 */
664/* Enable the directory cache and tagcache in RAM if we have 664/* Enable the directory cache and tagcache in RAM if we have
665 * plenty of RAM. Both features can be enabled independently. */ 665 * plenty of RAM. Both features can be enabled independently. */
666#if ((defined(MEMORYSIZE) && (MEMORYSIZE >= 8)) || MEM >= 8) && \ 666#if ((defined(MEMORYSIZE) && (MEMORYSIZE >= 8)) || MEM >= 8) && \
667 !defined(BOOTLOADER) && !defined(__PCTOOL__) 667 !defined(BOOTLOADER) && !defined(__PCTOOL__) && !defined(APPLICATION)
668#define HAVE_DIRCACHE 668#define HAVE_DIRCACHE
669#ifdef HAVE_TAGCACHE 669#ifdef HAVE_TAGCACHE
670#define HAVE_TC_RAMCACHE 670#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 @@
22#ifndef __INCLUDE_FILEFUNCS_H_ 22#ifndef __INCLUDE_FILEFUNCS_H_
23#define __INCLUDE_FILEFUNCS_H_ 23#define __INCLUDE_FILEFUNCS_H_
24 24
25#include <stdbool.h>
25#include "config.h" 26#include "config.h"
27#include "dir.h"
26 28
27#ifdef HAVE_MULTIVOLUME 29#ifdef HAVE_MULTIVOLUME
28int strip_volume(const char* name, char* namecopy); 30int strip_volume(const char* name, char* namecopy);
@@ -32,5 +34,6 @@ int strip_volume(const char* name, char* namecopy);
32bool file_exists(const char *file); 34bool file_exists(const char *file);
33bool dir_exists(const char *path); 35bool dir_exists(const char *path);
34#endif 36#endif
37extern struct dirinfo dir_get_info(struct DIR* parent, struct dirent *entry);
35 38
36#endif /* __INCLUDE_FILEFUNCS_H_ */ 39#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)
203} 203}
204#endif 204#endif
205 205
206#if (CONFIG_PLATFORM & PLATFORM_HOSTED) && !defined(PLUGIN) && !defined(CODEC)
207#define sleep(x) sim_sleep(x)
208#endif
209
210/* kernel functions */ 206/* kernel functions */
211extern void kernel_init(void) INIT_ATTR; 207extern void kernel_init(void) INIT_ATTR;
212extern void yield(void); 208extern void yield(void);
213extern void sleep(int ticks); 209extern unsigned sleep(unsigned ticks);
214int tick_add_task(void (*f)(void)); 210int tick_add_task(void (*f)(void));
215int tick_remove_task(void (*f)(void)); 211int tick_remove_task(void (*f)(void));
216extern void tick_start(unsigned int interval_in_ms) INIT_ATTR; 212extern 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 @@
22#include "config.h" 22#include "config.h"
23#include <stdio.h> 23#include <stdio.h>
24#include "general.h" 24#include "general.h"
25 25#include "file.h"
26#include "dir.h" 26#include "dir.h"
27#include "limits.h" 27#include "limits.h"
28#include "stdlib.h" 28#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 @@
41 41
42#endif 42#endif
43 43
44#define ATTR_READ_ONLY 0x01
45#define ATTR_HIDDEN 0x02
46#define ATTR_SYSTEM 0x04
47#define ATTR_VOLUME_ID 0x08
48#define ATTR_DIRECTORY 0x10
49#define ATTR_ARCHIVE 0x20
50#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
51
52#if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL))
44#ifdef HAVE_DIRCACHE 53#ifdef HAVE_DIRCACHE
45# include "dircache.h" 54# include "dircache.h"
46# define DIR DIR_CACHED 55# define DIR DIR_CACHED
@@ -62,5 +71,9 @@
62# define mkdir mkdir_uncached 71# define mkdir mkdir_uncached
63# define rmdir rmdir_uncached 72# define rmdir rmdir_uncached
64#endif 73#endif
74#else
75#include "dir_uncached.h"
76#include "dir-target.h"
77#endif
65 78
66#endif 79#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 @@
21#ifndef _DIR_UNCACHED_H_ 21#ifndef _DIR_UNCACHED_H_
22#define _DIR_UNCACHED_H_ 22#define _DIR_UNCACHED_H_
23 23
24#include "config.h"
25
26struct dirinfo {
27 int attribute;
28 long size;
29 unsigned short wrtdate;
30 unsigned short wrttime;
31};
32
33#ifndef APPLICATION
24#include <stdbool.h> 34#include <stdbool.h>
25#include "file.h" 35#include "file.h"
26 36
27#define ATTR_READ_ONLY 0x01 37#if (CONFIG_PLATFORM & PLATFORM_SDL)
28#define ATTR_HIDDEN 0x02
29#define ATTR_SYSTEM 0x04
30#define ATTR_VOLUME_ID 0x08
31#define ATTR_DIRECTORY 0x10
32#define ATTR_ARCHIVE 0x20
33#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
34
35#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
36#define dirent_uncached sim_dirent 38#define dirent_uncached sim_dirent
37#define DIR_UNCACHED SIM_DIR 39#define DIR_UNCACHED SIM_DIR
38#define opendir_uncached sim_opendir 40#define opendir_uncached sim_opendir
@@ -46,11 +48,8 @@
46 48
47struct dirent_uncached { 49struct dirent_uncached {
48 unsigned char d_name[MAX_PATH]; 50 unsigned char d_name[MAX_PATH];
49 int attribute; 51 struct dirinfo info;
50 long size;
51 long startcluster; 52 long startcluster;
52 unsigned short wrtdate; /* Last write date */
53 unsigned short wrttime; /* Last write time */
54}; 53};
55#endif 54#endif
56 55
@@ -92,5 +91,6 @@ extern struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir);
92extern int release_dirs(int volume); 91extern int release_dirs(int volume);
93 92
94#endif /* DIRFUNCTIONS_DEFINED */ 93#endif /* DIRFUNCTIONS_DEFINED */
94#endif
95 95
96#endif 96#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 {
63 63
64/* Exported structures. */ 64/* Exported structures. */
65struct dircache_entry { 65struct dircache_entry {
66 struct dirinfo info;
66 struct dircache_entry *next; 67 struct dircache_entry *next;
67 struct dircache_entry *up; 68 struct dircache_entry *up;
68 struct dircache_entry *down; 69 struct dircache_entry *down;
69 int attribute;
70 long size;
71 long startcluster; 70 long startcluster;
72 unsigned short wrtdate;
73 unsigned short wrttime;
74 unsigned long name_len; 71 unsigned long name_len;
75 char *d_name; 72 char *d_name;
76}; 73};
77 74
78struct dirent_cached { 75struct dirent_cached {
76 struct dirinfo info;
79 char *d_name; 77 char *d_name;
80 int attribute;
81 long size;
82 long startcluster; 78 long startcluster;
83 unsigned short wrtdate; /* Last write date */
84 unsigned short wrttime; /* Last write time */
85}; 79};
86 80
87typedef struct { 81typedef 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 @@
37#define MAX_OPEN_FILES 11 37#define MAX_OPEN_FILES 11
38 38
39#if !defined(PLUGIN) && !defined(CODEC) 39#if !defined(PLUGIN) && !defined(CODEC)
40#if (CONFIG_PLATFORM & PLATFORM_HOSTED) 40#if (CONFIG_PLATFORM & PLATFORM_SDL)
41#define open(x, ...) sim_open(x, __VA_ARGS__) 41#define open(x, ...) sim_open(x, __VA_ARGS__)
42#define creat(x,m) sim_creat(x,m) 42#define creat(x,m) sim_creat(x,m)
43#define remove(x) sim_remove(x) 43#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,
213/**************************************************************************** 213/****************************************************************************
214 * Thread stuff 214 * Thread stuff
215 ****************************************************************************/ 215 ****************************************************************************/
216void sleep(int ticks) 216unsigned sleep(unsigned ticks)
217{ 217{
218#if defined(CPU_PP) && defined(BOOTLOADER) 218#if defined(CPU_PP) && defined(BOOTLOADER)
219 unsigned stop = USEC_TIMER + ticks * (1000000/HZ); 219 unsigned stop = USEC_TIMER + ticks * (1000000/HZ);
@@ -229,6 +229,7 @@ void sleep(int ticks)
229 sleep_thread(ticks); 229 sleep_thread(ticks);
230 switch_thread(); 230 switch_thread();
231#endif 231#endif
232 return 0;
232} 233}
233 234
234void yield(void) 235void 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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __DIR_TARGET_H__
23#define __DIR_TARGET_H__
24
25#include <dirent.h>
26
27#define opendir _opendir
28#define mkdir _mkdir
29#define closedir _closedir
30#define readdir _readdir
31
32extern DIR* _opendir(const char* name);
33extern int _mkdir(const char* name);
34extern int _closedir(DIR* dir);
35extern struct dirent *_readdir(DIR* dir);
36
37#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdlib.h>
23#include <sys/stat.h> /* stat() */
24#include <stdio.h> /* snprintf */
25#include <string.h> /* size_t */
26#include <dirent.h>
27#include <time.h> /* localtime() */
28#include "system-target.h"
29#include "dir-target.h"
30#include "file.h"
31#include "dir.h"
32
33
34long filesize(int fd)
35{
36 struct stat buf;
37
38 if (!fstat(fd, &buf))
39 return buf.st_size;
40 else
41 return -1;
42}
43
44/* do we really need this in the app? */
45void fat_size(unsigned long* size, unsigned long* free)
46{
47 *size = *free = 0;
48}
49
50#undef opendir
51#undef closedir
52#undef mkdir
53#undef readdir
54
55/* need to wrap around DIR* because we need to save the parent's
56 * directory path in order to determine dirinfo */
57struct __dir {
58 DIR *dir;
59 char *path;
60};
61
62DIR* _opendir(const char *name)
63{
64 char *buf = malloc(sizeof(struct __dir) + strlen(name)+1);
65 if (!buf)
66 return NULL;
67
68 struct __dir *this = (struct __dir*)buf;
69
70 this->path = buf+sizeof(struct __dir);
71 /* definitely fits due to strlen() */
72 strcpy(this->path, name);
73
74 this->dir = opendir(name);
75
76 if (!this->dir)
77 {
78 free(buf);
79 return NULL;
80 }
81 return (DIR*)this;
82}
83
84int _mkdir(const char *name)
85{
86 return mkdir(name, 0777);
87}
88
89int _closedir(DIR *dir)
90{
91 struct __dir *this = (struct __dir*)dir;
92 int ret = closedir(this->dir);
93 free(this);
94 return ret;
95}
96
97struct dirent* _readdir(DIR* dir)
98{
99 struct __dir *d = (struct __dir*)dir;
100 return readdir(d->dir);
101}
102
103struct dirinfo dir_get_info(struct DIR* _parent, struct dirent *dir)
104{
105 struct __dir *parent = (struct __dir*)_parent;
106 struct stat s;
107 struct tm *tm;
108 struct dirinfo ret;
109 char path[MAX_PATH];
110
111 snprintf(path, sizeof(path), "%s/%s", parent->path, dir->d_name);
112 stat(path, &s);
113 memset(&ret, 0, sizeof(ret));
114
115 if (S_ISDIR(s.st_mode))
116 {
117 ret.attribute = ATTR_DIRECTORY;
118 }
119
120 ret.size = s.st_size;
121 tm = localtime(&(s.st_mtime));
122 ret.wrtdate = ((tm->tm_year - 80) << 9) |
123 ((tm->tm_mon + 1) << 5) |
124 tm->tm_mday;
125 ret.wrttime = (tm->tm_hour << 11) |
126 (tm->tm_min << 5) |
127 (tm->tm_sec >> 1);
128 return ret;
129}
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <string.h> /* size_t */
23#include "load_code.h"
24
25/* the load_code wrappers simply wrap, nothing to do */
26void *lc_open(const char *filename, char *buf, size_t buf_size)
27{
28 return _lc_open(filename, buf, buf_size);
29}
30
31void *lc_get_header(void *handle)
32{
33 return _lc_get_header(handle);
34}
35
36void lc_close(void *handle)
37{
38 _lc_close(handle);
39}
40
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
9backlight-sim.c 9backlight-sim.c
10#endif 10#endif
11 11
12#if !(CONFIG_PLATFORM & PLATFORM_ANDROID)
13io.c
14#endif
12/* this is still needed for application since it has some stubs */ 15/* this is still needed for application since it has some stubs */
13powermgmt-sim.c 16powermgmt-sim.c
14io.c
15sim_tasks.c 17sim_tasks.c
16stubs.c 18stubs.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;
158 158
159static int num_openfiles = 0; 159static int num_openfiles = 0;
160 160
161struct sim_dirent { 161/* from dir.h */
162 unsigned char d_name[MAX_PATH]; 162struct dirinfo {
163 int attribute; 163 int attribute;
164 long size; 164 long size;
165 unsigned short wrtdate;
166 unsigned short wrttime;
167};
168
169struct sim_dirent {
170 unsigned char d_name[MAX_PATH];
171 struct dirinfo info;
165 long startcluster; 172 long startcluster;
166 unsigned short wrtdate; /* Last write date */
167 unsigned short wrttime; /* Last write time */
168}; 173};
169 174
170struct dirstruct { 175struct dirstruct {
@@ -329,14 +334,14 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
329 334
330#define ATTR_DIRECTORY 0x10 335#define ATTR_DIRECTORY 0x10
331 336
332 secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0; 337 secret.info.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0;
333 secret.size = s.st_size; 338 secret.info.size = s.st_size;
334 339
335 tm = localtime(&(s.st_mtime)); 340 tm = localtime(&(s.st_mtime));
336 secret.wrtdate = ((tm->tm_year - 80) << 9) | 341 secret.info.wrtdate = ((tm->tm_year - 80) << 9) |
337 ((tm->tm_mon + 1) << 5) | 342 ((tm->tm_mon + 1) << 5) |
338 tm->tm_mday; 343 tm->tm_mday;
339 secret.wrttime = (tm->tm_hour << 11) | 344 secret.info.wrttime = (tm->tm_hour << 11) |
340 (tm->tm_min << 5) | 345 (tm->tm_min << 5) |
341 (tm->tm_sec >> 1); 346 (tm->tm_sec >> 1);
342 return &secret; 347 return &secret;