1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Daniel Stenberg
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 #include <applimits.h>
30 short attr
; /* FAT attributes + file type flags */
31 unsigned long time_write
; /* Last write time */
36 #define BROWSE_SELECTONLY 0x0001 /* exit on selecting a file */
37 #define BROWSE_NO_CONTEXT_MENU 0x0002 /* disable context menu */
38 #define BROWSE_SELECTED 0x0100 /* this bit is set if user selected item */
42 /* A big buffer with plenty of entry structs,
43 * contains all files and dirs in the current
44 * dir (with filters applied) */
47 int max_entries
; /* Max entries in the cache */
48 int name_buffer_size
; /* in bytes */
51 struct browse_context
{
53 unsigned flags
; /* ored BROWSE_* */
54 bool (*callback_show_item
)(char *name
, int attr
, struct tree_context
*tc
);
55 /* callback function to determine to show/hide
56 the item for custom browser */
57 char *title
; /* title of the browser. if set to NULL,
58 directory name is used. */
59 enum themable_icons icon
; /* title icon */
60 const char *root
; /* full path of start directory */
61 const char *selected
; /* name of selected file in the root */
62 char *buf
; /* buffer to store selected file */
63 size_t bufsize
; /* size of the buffer */
66 /* browser context for file or db */
68 /* The directory we are browsing */
69 char currdir
[MAX_PATH
];
70 /* the number of directories we have crossed from / */
72 /* The currently selected file/id3dbitem index (old dircursor+dirfile) */
74 /* The selected item in each directory crossed
75 * (used when we want to return back to a previouws directory)*/
76 int selected_item_history
[MAX_DIR_LEVELS
];
78 int firstpos
; /* which dir entry is on first
79 position in dir buffer */
80 int pos_history
[MAX_DIR_LEVELS
];
82 int *dirfilter
; /* file use */
83 int filesindir
; /* The number of files in the dircache */
84 int dirsindir
; /* file use */
85 int dirlength
; /* total number of entries in dir, incl. those not loaded */
87 int table_history
[MAX_DIR_LEVELS
]; /* db use */
88 int extra_history
[MAX_DIR_LEVELS
]; /* db use */
89 int currtable
; /* db use */
90 int currextra
; /* db use */
92 struct tree_cache cache
;
94 int sort_dir
; /* directory sort order */
95 struct browse_context
*browse
;
98 void tree_drawlists(void);
99 void tree_mem_init(void) INIT_ATTR
;
100 void tree_gui_init(void) INIT_ATTR
;
101 char* get_current_file(char* buffer
, size_t buffer_len
);
102 void set_dirfilter(int l_dirfilter
);
103 void set_current_file(const char *path
);
104 void browse_context_init(struct browse_context
*browse
,
105 int dirfilter
, unsigned flags
,
106 char *title
, enum themable_icons icon
,
107 const char *root
, const char *selected
);
108 int rockbox_browse(struct browse_context
*browse
);
109 bool create_playlist(void);
110 void resume_directory(const char *dir
);
112 /* it takes an int on windows */
113 #define getcwd_size_t int
115 #define getcwd_size_t size_t
117 char *getcwd(char *buf
, getcwd_size_t size
);
118 void reload_directory(void);
119 bool check_rockboxdir(void);
120 struct tree_context
* tree_get_context(void);
121 void tree_flush(void);
122 void tree_restore(void);
124 bool bookmark_play(char* resume_file
, int index
, int offset
, int seed
,
127 extern struct gui_synclist tree_lists
;