diff options
Diffstat (limited to 'apps/tree.h')
-rw-r--r-- | apps/tree.h | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/apps/tree.h b/apps/tree.h index c07b92f298..2b296050d3 100644 --- a/apps/tree.h +++ b/apps/tree.h | |||
@@ -26,26 +26,30 @@ | |||
26 | #include <file.h> | 26 | #include <file.h> |
27 | #include "icon.h" | 27 | #include "icon.h" |
28 | 28 | ||
29 | /* keep this struct compatible (total size and name member) | ||
30 | * with struct tagtree_entry (tagtree.h) */ | ||
29 | struct entry { | 31 | struct entry { |
30 | short attr; /* FAT attributes + file type flags */ | ||
31 | unsigned long time_write; /* Last write time */ | ||
32 | char *name; | 32 | char *name; |
33 | int attr; /* FAT attributes + file type flags */ | ||
34 | unsigned time_write; /* Last write time */ | ||
33 | }; | 35 | }; |
34 | 36 | ||
35 | |||
36 | #define BROWSE_SELECTONLY 0x0001 /* exit on selecting a file */ | 37 | #define BROWSE_SELECTONLY 0x0001 /* exit on selecting a file */ |
37 | #define BROWSE_NO_CONTEXT_MENU 0x0002 /* disable context menu */ | 38 | #define BROWSE_NO_CONTEXT_MENU 0x0002 /* disable context menu */ |
38 | #define BROWSE_SELECTED 0x0100 /* this bit is set if user selected item */ | 39 | #define BROWSE_SELECTED 0x0100 /* this bit is set if user selected item */ |
39 | 40 | ||
40 | struct tree_context; | 41 | struct tree_context; |
42 | |||
41 | struct tree_cache { | 43 | struct tree_cache { |
42 | /* A big buffer with plenty of entry structs, | 44 | /* A big buffer with plenty of entry structs, contains all files and dirs |
43 | * contains all files and dirs in the current | 45 | * in the current dir (with filters applied) |
44 | * dir (with filters applied) */ | 46 | * Note that they're buflib-allocated and can therefore possibly move |
45 | void* entries; | 47 | * They need to be locked if used around yielding functions */ |
46 | char* name_buffer; | 48 | int entries_handle; /* handle to the entry cache */ |
47 | int max_entries; /* Max entries in the cache */ | 49 | int name_buffer_handle; /* handle to the name cache */ |
48 | int name_buffer_size; /* in bytes */ | 50 | int max_entries; /* Max entries in the cache */ |
51 | int name_buffer_size; /* in bytes */ | ||
52 | volatile int lock_count; /* non-0 if buffers may not move */ | ||
49 | }; | 53 | }; |
50 | 54 | ||
51 | struct browse_context { | 55 | struct browse_context { |
@@ -95,6 +99,10 @@ struct tree_context { | |||
95 | struct browse_context *browse; | 99 | struct browse_context *browse; |
96 | }; | 100 | }; |
97 | 101 | ||
102 | /* | ||
103 | * Call one of the two below after yields since the entrys may move inbetween */ | ||
104 | struct entry* tree_get_entries(struct tree_context *t); | ||
105 | struct entry* tree_get_entry_at(struct tree_context *t, int index); | ||
98 | void tree_drawlists(void); | 106 | void tree_drawlists(void); |
99 | void tree_mem_init(void) INIT_ATTR; | 107 | void tree_mem_init(void) INIT_ATTR; |
100 | void tree_gui_init(void) INIT_ATTR; | 108 | void tree_gui_init(void) INIT_ATTR; |
@@ -108,6 +116,14 @@ void browse_context_init(struct browse_context *browse, | |||
108 | int rockbox_browse(struct browse_context *browse); | 116 | int rockbox_browse(struct browse_context *browse); |
109 | bool create_playlist(void); | 117 | bool create_playlist(void); |
110 | void resume_directory(const char *dir); | 118 | void resume_directory(const char *dir); |
119 | static inline void tree_lock_cache(struct tree_context *t) | ||
120 | { | ||
121 | t->cache.lock_count++; | ||
122 | } | ||
123 | static inline void tree_unlock_cache(struct tree_context *t) | ||
124 | { | ||
125 | t->cache.lock_count--; | ||
126 | } | ||
111 | #ifdef WIN32 | 127 | #ifdef WIN32 |
112 | /* it takes an int on windows */ | 128 | /* it takes an int on windows */ |
113 | #define getcwd_size_t int | 129 | #define getcwd_size_t int |