📄 dirlist.h
字号:
#include "malloc.h"// TODO: how deep can we go???#define MAX_SUBDIR_DEPTH 4struct filelist_struct { unsigned char attrib; // these first 5 items must exactly match unsigned char name_length; // what's written by dir_read_fast! char extension[3]; unsigned long cluster; unsigned long size; simm_id long_name; // Dynamic allocation for long file names char file_desc; // if open and some is cached simm_id /* filelist_t * */ prev; simm_id /* filelist_t * */ next;};typedef xdata struct filelist_struct filelist_t;struct dirlist_struct{ unsigned char attrib; // these first 5 items must exactly match unsigned char name_length; // what's written by dir_read_fast! char extension[3]; unsigned long cluster; unsigned long size; simm_id long_name; simm_id /* dirlist_t * */ subdir_start; simm_id /* dirlist_t * */ subdir_end; unsigned char open; // Are the contents of this directory displayed? (are we finished loading?) simm_id /* filelist_t * */ filelist_start; simm_id /* filelist_t * */ filelist_end; simm_id /* dirlist_t * */ next; simm_id /* dirlist_t * */ prev; simm_id /* dirlist_t * */ parent_dir; unsigned char treedir_expand;};typedef xdata struct dirlist_struct dirlist_t;/*struct stack_struct { simm_id name; simm_id item; simm_id next; simm_id prev;};typedef xdata struct stack_struct stack_t;*/struct m3u_parse_name_struct { xdata char *name; // data only valid when its in 0x4000 so simm_id not used simm_id next;};typedef xdata struct m3u_parse_name_struct m3u_parse_name_t;struct m3u_parse_list_struct { simm_id /*m3u_parse_name_t*/ *name; simm_id next;};typedef xdata struct m3u_parse_list_struct m3u_parse_list_t;extern simm_id /* dirlist_t * */ root;extern void dirlist_init();extern void dirlist_show();extern void m3u_list_show();extern unsigned char parse_next_m3u_line(xdata char fd);extern void m3u_add_file();extern void process_m3u();extern xdata char * full_pathname(simm_id dir);extern void test_new_fast_directory_read(void);extern xdata unsigned int mp3_file_count;extern xdata unsigned int m3u_file_count;extern xdata unsigned int total_file_count;extern xdata unsigned int directory_count;/* * * Okay.. Here's the gist on how all these crazy structures fit together.. .* * dirlist_struct is a structure for holding a directory entry. For example, * the root directory of the drive is one of these structures. Each dirlist * struct has two linked listed pointers inside of it. The first is the * subdirectory linked list. This is just another list of dirlist structs. (A * start and end record for the list) It is each directory under the "current" * directory... It's recursvive sort of thing and hard to explain... Maybe I * can draw a picture that would make more sense. (Attached) And then there is * a start and end to a linked list of filelist struct records which is the * list of all the files in that directory.* * Now the playlist parts...* * The playlist_list struct is a list of playlists ... This is the structure * that allows you to have multiple playlists in memory... So you have * multiple playlists and in a playlist is a linked list of playlist structs * and each record of that playlist struct points to one filelist struct * record thus you have a list of playlists of files. does this make sense.. I * know it's extremely complicated...* * The reason I keep all the directory lists cached is because in the very * near future I plan to add code to allow traversing the directory structure * on the screen.* * As far as making playlists have names by passing a parameter I would * seriously consider doing it this way... Allocate memory using simm_malloc * for the directory string and just pass the pointer returned by simm_malloc * to playlist_create after you have copied the string into it. Honestly, SDCC * seems to be quite buggy still and I really wouldn't trust it much... Also * beware, printf is very very VERY grouchy sometimes. It's a bug with the * DSEG something or another... I don't understand it completely... Paul said * something about it, your code may be working fine but if you try to print * something it may or may not work and cause crashing before you can tell * what is going on.. Printf works off a FIFO with the serial buffer so your * program may crash before your debug output shows up... I found that adding * a while(1) statement in key places to make it completely stop and finish * processing the output so I can see what is going on helps a ton.. I've * spent hours debugging and found it to be a printf that wouldn't print a * string right...* * I'll attach a picture that will help explain the data structures a bit * better...* * P.S. I am leaving the dirstruct stuff in memory because all said and done * it really won't take that much extra memory and it will make playlist * creation pretty slick I think...* * -Zach* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -