diff options
Diffstat (limited to 'apps/filetree.c')
-rw-r--r-- | apps/filetree.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index 1aee80b6b2..35bb2a8fd0 100644 --- a/apps/filetree.c +++ b/apps/filetree.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <limits.h> | 29 | #include <limits.h> |
30 | #include "bookmark.h" | 30 | #include "bookmark.h" |
31 | #include "tree.h" | 31 | #include "tree.h" |
32 | #include "core_alloc.h" | ||
32 | #include "settings.h" | 33 | #include "settings.h" |
33 | #include "filetypes.h" | 34 | #include "filetypes.h" |
34 | #include "talk.h" | 35 | #include "talk.h" |
@@ -60,7 +61,8 @@ int ft_build_playlist(struct tree_context* c, int start_index) | |||
60 | int i; | 61 | int i; |
61 | int start=start_index; | 62 | int start=start_index; |
62 | 63 | ||
63 | struct entry *entries = c->cache.entries; | 64 | tree_lock_cache(c); |
65 | struct entry *entries = tree_get_entries(c); | ||
64 | 66 | ||
65 | for(i = 0;i < c->filesindir;i++) | 67 | for(i = 0;i < c->filesindir;i++) |
66 | { | 68 | { |
@@ -77,6 +79,8 @@ int ft_build_playlist(struct tree_context* c, int start_index) | |||
77 | } | 79 | } |
78 | } | 80 | } |
79 | 81 | ||
82 | tree_unlock_cache(c); | ||
83 | |||
80 | return start_index; | 84 | return start_index; |
81 | } | 85 | } |
82 | 86 | ||
@@ -127,13 +131,15 @@ static void check_file_thumbnails(struct tree_context* c) | |||
127 | { | 131 | { |
128 | int i; | 132 | int i; |
129 | struct dirent *entry; | 133 | struct dirent *entry; |
130 | struct entry* entries = c->cache.entries; | 134 | struct entry* entries; |
131 | DIR *dir; | 135 | DIR *dir; |
132 | 136 | ||
133 | dir = opendir(c->currdir); | 137 | dir = opendir(c->currdir); |
134 | if(!dir) | 138 | if(!dir) |
135 | return; | 139 | return; |
136 | /* mark all files as non talking, except the .talk ones */ | 140 | /* mark all files as non talking, except the .talk ones */ |
141 | entries = tree_get_entries(c); | ||
142 | tree_lock_cache(c); | ||
137 | for (i=0; i < c->filesindir; i++) | 143 | for (i=0; i < c->filesindir; i++) |
138 | { | 144 | { |
139 | if (entries[i].attr & ATTR_DIRECTORY) | 145 | if (entries[i].attr & ATTR_DIRECTORY) |
@@ -177,6 +183,7 @@ static void check_file_thumbnails(struct tree_context* c) | |||
177 | } | 183 | } |
178 | } | 184 | } |
179 | } | 185 | } |
186 | tree_unlock_cache(c); | ||
180 | closedir(dir); | 187 | closedir(dir); |
181 | } | 188 | } |
182 | 189 | ||
@@ -287,11 +294,11 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
287 | c->dirsindir = 0; | 294 | c->dirsindir = 0; |
288 | c->dirfull = false; | 295 | c->dirfull = false; |
289 | 296 | ||
297 | tree_lock_cache(c); | ||
290 | while ((entry = readdir(dir))) { | 298 | while ((entry = readdir(dir))) { |
291 | int len; | 299 | int len; |
292 | struct dirinfo info; | 300 | struct dirinfo info; |
293 | struct entry* table = c->cache.entries; | 301 | struct entry* dptr = tree_get_entry_at(c, files_in_dir); |
294 | struct entry* dptr = &table[files_in_dir]; | ||
295 | if (!entry) | 302 | if (!entry) |
296 | break; | 303 | break; |
297 | 304 | ||
@@ -369,7 +376,7 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
369 | 376 | ||
370 | ++files_in_dir; | 377 | ++files_in_dir; |
371 | 378 | ||
372 | dptr->name = &c->cache.name_buffer[name_buffer_used]; | 379 | dptr->name = core_get_data(c->cache.name_buffer_handle)+name_buffer_used; |
373 | dptr->time_write = | 380 | dptr->time_write = |
374 | (long)info.wrtdate<<16 | | 381 | (long)info.wrtdate<<16 | |
375 | (long)info.wrttime; /* in one # */ | 382 | (long)info.wrttime; /* in one # */ |
@@ -384,13 +391,14 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
384 | closedir(dir); | 391 | closedir(dir); |
385 | 392 | ||
386 | compare_sort_dir = c->sort_dir; | 393 | compare_sort_dir = c->sort_dir; |
387 | qsort(c->cache.entries, files_in_dir, sizeof(struct entry), compare); | 394 | qsort(tree_get_entries(c), files_in_dir, sizeof(struct entry), compare); |
388 | 395 | ||
389 | /* If thumbnail talking is enabled, make an extra run to mark files with | 396 | /* If thumbnail talking is enabled, make an extra run to mark files with |
390 | associated thumbnails, so we don't do unsuccessful spinups later. */ | 397 | associated thumbnails, so we don't do unsuccessful spinups later. */ |
391 | if (global_settings.talk_file_clip) | 398 | if (global_settings.talk_file_clip) |
392 | check_file_thumbnails(c); /* map .talk to ours */ | 399 | check_file_thumbnails(c); /* map .talk to ours */ |
393 | 400 | ||
401 | tree_unlock_cache(c); | ||
394 | return 0; | 402 | return 0; |
395 | } | 403 | } |
396 | #ifdef HAVE_LCD_BITMAP | 404 | #ifdef HAVE_LCD_BITMAP |
@@ -424,15 +432,15 @@ int ft_enter(struct tree_context* c) | |||
424 | { | 432 | { |
425 | int rc = GO_TO_PREVIOUS; | 433 | int rc = GO_TO_PREVIOUS; |
426 | char buf[MAX_PATH]; | 434 | char buf[MAX_PATH]; |
427 | struct entry* table = c->cache.entries; | 435 | struct entry* file = tree_get_entry_at(c, c->selected_item); |
428 | struct entry *file = &table[c->selected_item]; | 436 | int file_attr = file->attr; |
429 | 437 | ||
430 | if (c->currdir[1]) | 438 | if (c->currdir[1]) |
431 | snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name); | 439 | snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name); |
432 | else | 440 | else |
433 | snprintf(buf,sizeof(buf),"/%s",file->name); | 441 | snprintf(buf,sizeof(buf),"/%s",file->name); |
434 | 442 | ||
435 | if (file->attr & ATTR_DIRECTORY) { | 443 | if (file_attr & ATTR_DIRECTORY) { |
436 | memcpy(c->currdir, buf, sizeof(c->currdir)); | 444 | memcpy(c->currdir, buf, sizeof(c->currdir)); |
437 | if ( c->dirlevel < MAX_DIR_LEVELS ) | 445 | if ( c->dirlevel < MAX_DIR_LEVELS ) |
438 | c->selected_item_history[c->dirlevel] = c->selected_item; | 446 | c->selected_item_history[c->dirlevel] = c->selected_item; |
@@ -444,7 +452,7 @@ int ft_enter(struct tree_context* c) | |||
444 | bool play = false; | 452 | bool play = false; |
445 | int start_index=0; | 453 | int start_index=0; |
446 | 454 | ||
447 | switch ( file->attr & FILE_ATTR_MASK ) { | 455 | switch ( file_attr & FILE_ATTR_MASK ) { |
448 | case FILE_ATTR_M3U: | 456 | case FILE_ATTR_M3U: |
449 | if (!bookmark_autoload(buf)) | 457 | if (!bookmark_autoload(buf)) |
450 | playlist_viewer_ex(buf); | 458 | playlist_viewer_ex(buf); |
@@ -612,7 +620,7 @@ int ft_enter(struct tree_context* c) | |||
612 | char *plugin = buf, *argument = NULL, lua_path[MAX_PATH]; | 620 | char *plugin = buf, *argument = NULL, lua_path[MAX_PATH]; |
613 | int ret; | 621 | int ret; |
614 | 622 | ||
615 | if ((file->attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) { | 623 | if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) { |
616 | snprintf(lua_path, sizeof(lua_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */ | 624 | snprintf(lua_path, sizeof(lua_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */ |
617 | plugin = lua_path; | 625 | plugin = lua_path; |
618 | argument = buf; | 626 | argument = buf; |
@@ -658,6 +666,7 @@ int ft_enter(struct tree_context* c) | |||
658 | break; | 666 | break; |
659 | } | 667 | } |
660 | 668 | ||
669 | struct entry* file = tree_get_entry_at(c, c->selected_item); | ||
661 | plugin = filetype_get_plugin(file); | 670 | plugin = filetype_get_plugin(file); |
662 | if (plugin) | 671 | if (plugin) |
663 | { | 672 | { |