annotate libmenu/menu_filesel.c @ 20159:5bb2619601f2

Remove old hack to search for .ar and VIDO, we know where they are
author rtogni
date Wed, 11 Oct 2006 21:19:24 +0000
parents 10d8f2cae948
children 543f6e8deeb6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
1
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
2 #include <stdlib.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
3 #include <stdio.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
4 #include <dirent.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
5 #include <errno.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
6 #include <string.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
7 #include <sys/types.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
8 #include <sys/stat.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
9 #include <ctype.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
10 #include <unistd.h>
8291
abe95dde3223 limits.h required to get a PATH_MAX definition (on solaris)
jkeil
parents: 8226
diff changeset
11 #include <limits.h>
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
12
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
13
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 16061
diff changeset
14 #include "config.h"
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
15 #include "mp_msg.h"
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
16 #include "help_mp.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
17
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 16061
diff changeset
18 #include "m_struct.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 16061
diff changeset
19 #include "m_option.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
20
19431
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 17994
diff changeset
21 #include "libmpcodecs/img_format.h"
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 17994
diff changeset
22 #include "libmpcodecs/mp_image.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
23
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
24 #include "menu.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
25 #include "menu_list.h"
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 16061
diff changeset
26 #include "input/input.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 16061
diff changeset
27 #include "osdep/keycodes.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
28
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
29 struct list_entry_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
30 struct list_entry p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
31 int d;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
32 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
33
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
34 struct menu_priv_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
35 menu_list_priv_t p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
36 char* dir; // current dir
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
37 /// Cfg fields
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
38 char* path;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
39 char* title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
40 char* file_action;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
41 char* dir_action;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
42 int auto_close;
19490
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
43 char** actions;
19491
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
44 char* filter;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
45 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
46
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
47 static struct menu_priv_s cfg_dflt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
48 MENU_LIST_PRIV_DFLT,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
49 NULL,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
50
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
51 NULL,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
52 "Select a file: %p",
8226
4b8fcc2af8f1 quote the filenames
albeu
parents: 8197
diff changeset
53 "loadfile '%p'",
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
54 NULL,
19490
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
55 0,
19491
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
56 NULL,
19490
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
57 NULL
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
58 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
59
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
60 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
61
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
62 static m_option_t cfg_fields[] = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
63 MENU_LIST_PRIV_FIELDS,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
64 { "path", ST_OFF(path), CONF_TYPE_STRING, 0, 0, 0, NULL },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
65 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
66 { "file-action", ST_OFF(file_action), CONF_TYPE_STRING, 0, 0, 0, NULL },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
67 { "dir-action", ST_OFF(dir_action), CONF_TYPE_STRING, 0, 0, 0, NULL },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
68 { "auto-close", ST_OFF(auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL },
19490
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
69 { "actions", ST_OFF(actions), CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
19491
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
70 { "filter", ST_OFF(filter), CONF_TYPE_STRING, 0, 0, 0, NULL},
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
71 { NULL, NULL, NULL, 0,0,0,NULL }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
72 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
73
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
74 #define mpriv (menu->priv)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
75
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
76 static void free_entry(list_entry_t* entry) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
77 free(entry->p.txt);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
78 free(entry);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
79 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
80
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
81 static char* replace_path(char* title , char* dir) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
82 char *p = strstr(title,"%p");
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
83 if(p) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
84 int tl = strlen(title);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
85 int dl = strlen(dir);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
86 int t1l = p-title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
87 int l = tl - 2 + dl;
10624
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
88 char *r, *n, *d = dir;
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
89 char term = *(p-1);
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
90
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
91 do {
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
92 if (*d == '\\' || *d == term)
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
93 l++;
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
94 } while (*d++);
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
95 r = malloc(l + 1);
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
96 n = r + t1l;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
97 memcpy(r,title,t1l);
10624
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
98 do {
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
99 if (*dir == '\\' || *dir == term)
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
100 *n++ = '\\';
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
101 } while ((*n++ = *dir++));
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
102 if(tl - t1l - 2 > 0)
10624
cdfd4a43c406 I've juste found a bug which prevent to load a file whose name contain
albeu
parents: 9380
diff changeset
103 strcpy(n-1,p+2);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
104 return r;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
105 } else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
106 return title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
107 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
108
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
109 typedef int (*kill_warn)(const void*, const void*);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
110
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
111 static int mylstat(char *dir, char *file,struct stat* st) {
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
112 int l = strlen(dir) + strlen(file);
8613
f88ba181ecf2 some 10l bugfixes
arpi
parents: 8358
diff changeset
113 char s[l+2];
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
114 sprintf(s,"%s/%s",dir,file);
9249
8546faeb0112 lstat->stat
arpi
parents: 9104
diff changeset
115 return stat(s,st);
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
116 }
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
117
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
118 static int compare(char **a, char **b){
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
119 if((*a)[strlen(*a) - 1] == '/') {
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
120 if((*b)[strlen(*b) - 1] == '/')
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
121 return strcmp(*b, *a) ;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
122 else
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
123 return 1;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
124 } else {
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
125 if((*b)[strlen(*b) - 1] == '/')
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
126 return -1;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
127 else
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
128 return strcmp(*b, *a);
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
129 }
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
130 }
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
131
19491
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
132 static char **get_extensions(menu_t *menu){
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
133 char **extensions, ext[32];
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
134 FILE *fp;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
135 int n = 1;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
136
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
137 if (!mpriv->filter)
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
138 return NULL;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
139
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
140 fp = fopen(mpriv->filter, "r");
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
141 if(!fp)
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
142 return NULL;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
143
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
144 extensions = (char **) malloc(sizeof(*extensions));
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
145 *extensions = NULL;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
146
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
147 while(fgets(ext,sizeof(ext),fp)) {
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
148 char **l, *e;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
149 int s = strlen (ext);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
150
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
151 if(ext[s-1] == '\n') {
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
152 ext[s-1] = '\0';
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
153 s--;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
154 }
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
155 e = (char *) malloc(s+1);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
156 extensions = (char **) realloc(extensions, ++n * sizeof(*extensions));
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
157 extensions = (char **) realloc(extensions, ++n * sizeof(*extensions));
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
158 strcpy (e, ext);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
159 for (l=extensions; *l; l++);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
160 *l++ = e;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
161 *l = NULL;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
162 }
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
163
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
164 fclose (fp);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
165 return extensions;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
166 }
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
167
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
168 static void free_extensions(char **extensions){
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
169 if (extensions) {
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
170 char **l = extensions;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
171 while (*l)
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
172 free (*l++);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
173 free (extensions);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
174 }
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
175 }
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
176
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
177 static int open_dir(menu_t* menu,char* args) {
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
178 char **namelist, **tp;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
179 struct dirent *dp;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
180 struct stat st;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
181 int n;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
182 char* p = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
183 list_entry_t* e;
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
184 DIR* dirp;
19491
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
185 extern int file_filter;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
186 char **extensions, **elem, *ext;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
187
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
188 menu_list_init(menu);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
189
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
190 if(mpriv->dir)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
191 free(mpriv->dir);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
192 mpriv->dir = strdup(args);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
193 if(mpriv->p.title && mpriv->p.title != mpriv->title && mpriv->p.title != cfg_dflt.p.title)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
194 free(mpriv->p.title);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
195 p = strstr(mpriv->title,"%p");
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
196
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
197 mpriv->p.title = replace_path(mpriv->title,mpriv->dir);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
198
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
199 if ((dirp = opendir (mpriv->dir)) == NULL){
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
200 mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_OpendirError, strerror(errno));
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
201 return 0;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
202 }
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
203
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
204 namelist = (char **) malloc(sizeof(char *));
19491
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
205 extensions = get_extensions(menu);
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
206
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
207 n=0;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
208 while ((dp = readdir(dirp)) != NULL) {
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
209 if(dp->d_name[0] == '.' && strcmp(dp->d_name,"..") != 0)
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
210 continue;
19491
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
211 mylstat(args,dp->d_name,&st);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
212 if (file_filter && extensions && !S_ISDIR(st.st_mode)) {
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
213 if((ext = strrchr(dp->d_name,'.')) == NULL)
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
214 continue;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
215 ext++;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
216 elem = extensions;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
217 do {
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
218 if (!strcasecmp(ext, *elem))
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
219 break;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
220 } while (*++elem);
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
221 if (*elem == NULL)
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
222 continue;
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
223 }
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
224 if(n%20 == 0){ // Get some more mem
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
225 if((tp = (char **) realloc(namelist, (n+20) * sizeof (char *)))
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
226 == NULL) {
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
227 mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReallocError, strerror(errno));
9104
a0aacfb492a5 Also attached some cleanup to menu_filesel.c, mainly to make it more
arpi
parents: 8853
diff changeset
228 n--;
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
229 goto bailout;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
230 }
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
231 namelist=tp;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
232 }
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
233
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
234 namelist[n] = (char *) malloc(strlen(dp->d_name) + 2);
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
235 if(namelist[n] == NULL){
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
236 mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_MallocError, strerror(errno));
9104
a0aacfb492a5 Also attached some cleanup to menu_filesel.c, mainly to make it more
arpi
parents: 8853
diff changeset
237 n--;
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
238 goto bailout;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
239 }
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
240
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
241 strcpy(namelist[n], dp->d_name);
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
242 if(S_ISDIR(st.st_mode))
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
243 strcat(namelist[n], "/");
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
244 n++;
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
245 }
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
246
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
247 bailout:
19491
10d8f2cae948 added new filter option to menu file browser to only display some files according to extension
ben
parents: 19490
diff changeset
248 free_extensions (extensions);
16061
261022c048cd add some closedir() to fix some opendir() leaks
aurel
parents: 10624
diff changeset
249 closedir(dirp);
261022c048cd add some closedir() to fix some opendir() leaks
aurel
parents: 10624
diff changeset
250
9104
a0aacfb492a5 Also attached some cleanup to menu_filesel.c, mainly to make it more
arpi
parents: 8853
diff changeset
251 qsort(namelist, n, sizeof(char *), (kill_warn)compare);
a0aacfb492a5 Also attached some cleanup to menu_filesel.c, mainly to make it more
arpi
parents: 8853
diff changeset
252
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
253 if (n < 0) {
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
254 mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReaddirError,strerror(errno));
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
255 return 0;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
256 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
257 while(n--) {
9104
a0aacfb492a5 Also attached some cleanup to menu_filesel.c, mainly to make it more
arpi
parents: 8853
diff changeset
258 if((e = calloc(1,sizeof(list_entry_t))) != NULL){
8613
f88ba181ecf2 some 10l bugfixes
arpi
parents: 8358
diff changeset
259 e->p.next = NULL;
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
260 e->p.txt = strdup(namelist[n]);
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
261 if(strchr(namelist[n], '/') != NULL)
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
262 e->d = 1;
8358
ecf6a4cf3272 No scandir() an no functions defined within other functions.
arpi
parents: 8291
diff changeset
263 menu_list_add_entry(menu,e);
9104
a0aacfb492a5 Also attached some cleanup to menu_filesel.c, mainly to make it more
arpi
parents: 8853
diff changeset
264 }else{
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
265 mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_MallocError, strerror(errno));
9104
a0aacfb492a5 Also attached some cleanup to menu_filesel.c, mainly to make it more
arpi
parents: 8853
diff changeset
266 }
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
267 free(namelist[n]);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
268 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
269 free(namelist);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
270
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
271 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
272 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
273
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
274
19490
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
275 static char *action;
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
276
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
277 static void read_cmd(menu_t* menu,int cmd) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
278 mp_cmd_t* c = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
279 switch(cmd) {
17945
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
280 case MENU_CMD_LEFT:
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
281 mpriv->p.current = mpriv->p.menu; // Hack : we consider that the first entry is ../
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
282 case MENU_CMD_RIGHT:
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
283 case MENU_CMD_OK: {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
284 // Directory
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
285 if(mpriv->p.current->d) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
286 if(mpriv->dir_action) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
287 int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
288 char filename[fname_len];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
289 char* str;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
290 sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
291 str = replace_path(mpriv->dir_action,filename);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
292 c = mp_input_parse_cmd(str);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
293 if(str != mpriv->dir_action)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
294 free(str);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
295 } else { // Default action : open this dirctory ourself
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
296 int l = strlen(mpriv->dir);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
297 char *slash = NULL, *p = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
298 if(strcmp(mpriv->p.current->p.txt,"../") == 0) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
299 if(l <= 1) break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
300 mpriv->dir[l-1] = '\0';
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
301 slash = strrchr(mpriv->dir,'/');
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
302 if(!slash) break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
303 slash[1] = '\0';
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
304 p = strdup(mpriv->dir);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
305 } else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
306 p = malloc(l + strlen(mpriv->p.current->p.txt) + 1);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
307 sprintf(p,"%s%s",mpriv->dir,mpriv->p.current->p.txt);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
308 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
309 menu_list_uninit(menu,free_entry);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
310 if(!open_dir(menu,p)) {
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
311 mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_CantOpenDirectory,p);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
312 menu->cl = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
313 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
314 free(p);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
315 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
316 } else { // Files
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
317 int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
318 char filename[fname_len];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
319 char *str;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
320 sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
321 str = replace_path(mpriv->file_action,filename);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
322 c = mp_input_parse_cmd(str);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
323 if(str != mpriv->file_action)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
324 free(str);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
325 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
326 if(c) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
327 mp_input_queue_cmd(c);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
328 if(mpriv->auto_close)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
329 menu->cl = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
330 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
331 } break;
19490
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
332 case MENU_CMD_ACTION: {
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
333 int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1;
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
334 char filename[fname_len];
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
335 char *str;
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
336 sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt);
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
337 str = replace_path(action, filename);
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
338 mp_input_queue_cmd(mp_input_parse_cmd(str));
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
339 if(str != action)
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
340 free(str);
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
341 } break;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
342 default:
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
343 menu_list_read_cmd(menu,cmd);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
344 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
345 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
346
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
347 static void read_key(menu_t* menu,int c){
17945
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
348 if(c == KEY_BS)
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
349 read_cmd(menu,MENU_CMD_LEFT);
19490
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
350 else {
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
351 char **str;
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
352 for (str=mpriv->actions; str && *str; str++)
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
353 if (c == (*str)[0]) {
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
354 action = &(*str)[2];
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
355 read_cmd(menu,MENU_CMD_ACTION);
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
356 break;
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
357 }
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
358 if (!str || !*str)
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
359 menu_list_read_key(menu,c,1);
f57977ac0394 support multiple actions in menu's file browser using key bindings
ben
parents: 19431
diff changeset
360 }
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
361 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
362
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
363 static void clos(menu_t* menu) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
364 menu_list_uninit(menu,free_entry);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
365 free(mpriv->dir);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
366 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
367
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
368 static int open_fs(menu_t* menu, char* args) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
369 char *path = mpriv->path;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
370 int r = 0;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
371 char wd[PATH_MAX+1];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
372 args = NULL; // Warning kill
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
373
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
374 menu->draw = menu_list_draw;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
375 menu->read_cmd = read_cmd;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
376 menu->read_key = read_key;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
377 menu->close = clos;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
378
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
379 getcwd(wd,PATH_MAX);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
380 if(!path || path[0] == '\0') {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
381 int l = strlen(wd) + 2;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
382 char b[l];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
383 sprintf(b,"%s/",wd);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
384 r = open_dir(menu,b);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
385 } else if(path[0] != '/') {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
386 int al = strlen(path);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
387 int l = strlen(wd) + al + 3;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
388 char b[l];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
389 if(b[al-1] != '/')
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
390 sprintf(b,"%s/%s/",wd,path);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
391 else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
392 sprintf(b,"%s/%s",wd,path);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
393 r = open_dir(menu,b);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
394 } else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
395 r = open_dir(menu,path);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
396
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
397 return r;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
398 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
399
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
400 const menu_info_t menu_info_filesel = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
401 "File seletor menu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
402 "filesel",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
403 "Albeu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
404 "",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
405 {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
406 "fs_cfg",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
407 sizeof(struct menu_priv_s),
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
408 &cfg_dflt,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
409 cfg_fields
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
410 },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
411 open_fs
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
412 };