Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: some propositions
From: Paul Suade (paul.suade_at_laposte.net)
Date: 2002-06-22


> Hi,all
>
> I'd like to propose to update the following structure to store the directory
entries :
>
> in file: apps\tree.c
>
> struct entry {
> bool file; /* true if file, false if dir */
> char name[TREE_MAX_FILENAMELEN];
> };

One possibility :

struct entry {
  int type; /* bit 31 = 0 if file, bit 0..30 = type */
  char name[TREE_MAX_FILENAMELEN];
};

To test if a file, just the following conditional (e->type >= 0) which gives a
good code (just one opcode !).

Or another one :

struct entry {
  struct vmt_entry *vmt;
  char name[TREE_MAX_FILENAMELEN];
};

struct vmt_entry {
  bool (*is_file) ();
  int (*type) ();
  ... (*tree_enter) (...);
  ...
};

This one would need more drastic changes in source, but it calls the right
functions without wasting time in switch statement.
For each new file type just intance a new vmt with the right functions pointers
to handle this kind of file. You still need a type factory function with a
switch statement to set the right vmt on an entry.



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa