diff options
author | Kevin Ferrare <kevin@rockbox.org> | 2007-07-20 17:06:55 +0000 |
---|---|---|
committer | Kevin Ferrare <kevin@rockbox.org> | 2007-07-20 17:06:55 +0000 |
commit | 011a325e32c05f6e4817dcdc555615e6b7b6c102 (patch) | |
tree | ab22ab91b99524dba823cda861b17520db030911 | |
parent | 930278bcc0fd944ec50f30074b53b4c7cf0e3ccf (diff) | |
download | rockbox-011a325e32c05f6e4817dcdc555615e6b7b6c102.tar.gz rockbox-011a325e32c05f6e4817dcdc555615e6b7b6c102.zip |
Makes apps and plugins interract with directories using a posix-like api instead of calling dircache / simulator functions (no additionnal layer added, only a cosmetic change)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13943 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/filetree.c | 21 | ||||
-rw-r--r-- | apps/playlist.c | 1 | ||||
-rw-r--r-- | apps/plugin.c | 17 | ||||
-rw-r--r-- | apps/plugin.h | 23 | ||||
-rw-r--r-- | apps/plugins/doom/rockdoom.c | 8 | ||||
-rw-r--r-- | apps/plugins/doom/rockmacros.h | 11 | ||||
-rw-r--r-- | apps/plugins/properties.c | 53 | ||||
-rw-r--r-- | apps/plugins/rockboy/rockboy.c | 6 | ||||
-rw-r--r-- | apps/plugins/rockboy/rockmacros.h | 13 | ||||
-rw-r--r-- | apps/plugins/rockpaint.c | 22 | ||||
-rw-r--r-- | apps/tagcache.c | 24 | ||||
-rw-r--r-- | apps/tree.c | 10 | ||||
-rw-r--r-- | firmware/SOURCES | 2 | ||||
-rw-r--r-- | firmware/common/dir_uncached.c (renamed from firmware/common/dir.c) | 60 | ||||
-rw-r--r-- | firmware/common/dircache.c | 48 | ||||
-rw-r--r-- | firmware/common/disk.c | 4 | ||||
-rw-r--r-- | firmware/common/file.c | 28 | ||||
-rw-r--r-- | firmware/include/dir.h | 88 | ||||
-rw-r--r-- | firmware/include/dir_uncached.h | 91 | ||||
-rw-r--r-- | firmware/include/dircache.h | 26 |
20 files changed, 255 insertions, 301 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index 90b234a605..bc4709baab 100644 --- a/apps/filetree.c +++ b/apps/filetree.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include "plugin.h" | 38 | #include "plugin.h" |
39 | #include "rolo.h" | 39 | #include "rolo.h" |
40 | #include "sprintf.h" | 40 | #include "sprintf.h" |
41 | #include "dircache.h" | ||
42 | #include "splash.h" | 41 | #include "splash.h" |
43 | #include "yesno.h" | 42 | #include "yesno.h" |
44 | #include "cuesheet.h" | 43 | #include "cuesheet.h" |
@@ -84,11 +83,11 @@ int ft_build_playlist(struct tree_context* c, int start_index) | |||
84 | static void check_file_thumbnails(struct tree_context* c) | 83 | static void check_file_thumbnails(struct tree_context* c) |
85 | { | 84 | { |
86 | int i; | 85 | int i; |
87 | struct dircache_entry *entry; | 86 | struct dirent *entry; |
88 | struct entry* dircache = c->dircache; | 87 | struct entry* dircache = c->dircache; |
89 | DIRCACHED *dir; | 88 | DIR *dir; |
90 | 89 | ||
91 | dir = opendir_cached(c->currdir); | 90 | dir = opendir(c->currdir); |
92 | if(!dir) | 91 | if(!dir) |
93 | return; | 92 | return; |
94 | /* mark all files as non talking, except the .talk ones */ | 93 | /* mark all files as non talking, except the .talk ones */ |
@@ -109,7 +108,7 @@ static void check_file_thumbnails(struct tree_context* c) | |||
109 | } | 108 | } |
110 | } | 109 | } |
111 | 110 | ||
112 | while((entry = readdir_cached(dir)) != 0) /* walk directory */ | 111 | while((entry = readdir(dir)) != 0) /* walk directory */ |
113 | { | 112 | { |
114 | int ext_pos; | 113 | int ext_pos; |
115 | 114 | ||
@@ -135,7 +134,7 @@ static void check_file_thumbnails(struct tree_context* c) | |||
135 | } | 134 | } |
136 | } | 135 | } |
137 | } | 136 | } |
138 | closedir_cached(dir); | 137 | closedir(dir); |
139 | } | 138 | } |
140 | 139 | ||
141 | /* support function for qsort() */ | 140 | /* support function for qsort() */ |
@@ -209,12 +208,12 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
209 | { | 208 | { |
210 | int i; | 209 | int i; |
211 | int name_buffer_used = 0; | 210 | int name_buffer_used = 0; |
212 | DIRCACHED *dir; | 211 | DIR *dir; |
213 | 212 | ||
214 | if (tempdir) | 213 | if (tempdir) |
215 | dir = opendir_cached(tempdir); | 214 | dir = opendir(tempdir); |
216 | else | 215 | else |
217 | dir = opendir_cached(c->currdir); | 216 | dir = opendir(c->currdir); |
218 | if(!dir) | 217 | if(!dir) |
219 | return -1; /* not a directory */ | 218 | return -1; /* not a directory */ |
220 | 219 | ||
@@ -223,7 +222,7 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
223 | 222 | ||
224 | for ( i=0; i < global_settings.max_files_in_dir; i++ ) { | 223 | for ( i=0; i < global_settings.max_files_in_dir; i++ ) { |
225 | int len; | 224 | int len; |
226 | struct dircache_entry *entry = readdir_cached(dir); | 225 | struct dirent *entry = readdir(dir); |
227 | struct entry* dptr = | 226 | struct entry* dptr = |
228 | (struct entry*)(c->dircache + i * sizeof(struct entry)); | 227 | (struct entry*)(c->dircache + i * sizeof(struct entry)); |
229 | if (!entry) | 228 | if (!entry) |
@@ -301,7 +300,7 @@ int ft_load(struct tree_context* c, const char* tempdir) | |||
301 | } | 300 | } |
302 | c->filesindir = i; | 301 | c->filesindir = i; |
303 | c->dirlength = i; | 302 | c->dirlength = i; |
304 | closedir_cached(dir); | 303 | closedir(dir); |
305 | 304 | ||
306 | qsort(c->dircache,i,sizeof(struct entry),compare); | 305 | qsort(c->dircache,i,sizeof(struct entry),compare); |
307 | 306 | ||
diff --git a/apps/playlist.c b/apps/playlist.c index 7b1b91e123..f0ac29d1ef 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -88,7 +88,6 @@ | |||
88 | #include "button.h" | 88 | #include "button.h" |
89 | #include "filetree.h" | 89 | #include "filetree.h" |
90 | #include "abrepeat.h" | 90 | #include "abrepeat.h" |
91 | #include "dircache.h" | ||
92 | #include "thread.h" | 91 | #include "thread.h" |
93 | #include "usb.h" | 92 | #include "usb.h" |
94 | #include "filetypes.h" | 93 | #include "filetypes.h" |
diff --git a/apps/plugin.c b/apps/plugin.c index aff24e0059..68b430d2f3 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -222,18 +222,11 @@ static const struct plugin_api rockbox_api = { | |||
222 | create_numbered_filename, | 222 | create_numbered_filename, |
223 | 223 | ||
224 | /* dir */ | 224 | /* dir */ |
225 | PREFIX(opendir), | 225 | opendir, |
226 | PREFIX(closedir), | 226 | closedir, |
227 | PREFIX(readdir), | 227 | readdir, |
228 | PREFIX(mkdir), | 228 | mkdir, |
229 | PREFIX(rmdir), | 229 | rmdir, |
230 | |||
231 | /* dir, cached */ | ||
232 | #ifdef HAVE_DIRCACHE | ||
233 | opendir_cached, | ||
234 | readdir_cached, | ||
235 | closedir_cached, | ||
236 | #endif | ||
237 | 230 | ||
238 | /* kernel/ system */ | 231 | /* kernel/ system */ |
239 | PREFIX(sleep), | 232 | PREFIX(sleep), |
diff --git a/apps/plugin.h b/apps/plugin.h index 920d804ab5..ac6988152a 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -37,9 +37,6 @@ | |||
37 | #include "config.h" | 37 | #include "config.h" |
38 | #include "system.h" | 38 | #include "system.h" |
39 | #include "dir.h" | 39 | #include "dir.h" |
40 | #ifndef SIMULATOR | ||
41 | #include "dircache.h" | ||
42 | #endif | ||
43 | #include "kernel.h" | 40 | #include "kernel.h" |
44 | #include "thread.h" | 41 | #include "thread.h" |
45 | #include "button.h" | 42 | #include "button.h" |
@@ -115,12 +112,12 @@ | |||
115 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 112 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
116 | 113 | ||
117 | /* increase this every time the api struct changes */ | 114 | /* increase this every time the api struct changes */ |
118 | #define PLUGIN_API_VERSION 62 | 115 | #define PLUGIN_API_VERSION 63 |
119 | 116 | ||
120 | /* update this to latest version if a change to the api struct breaks | 117 | /* update this to latest version if a change to the api struct breaks |
121 | backwards compatibility (and please take the opportunity to sort in any | 118 | backwards compatibility (and please take the opportunity to sort in any |
122 | new function which are "waiting" at the end of the function table) */ | 119 | new function which are "waiting" at the end of the function table) */ |
123 | #define PLUGIN_MIN_API_VERSION 62 | 120 | #define PLUGIN_MIN_API_VERSION 63 |
124 | 121 | ||
125 | /* plugin return codes */ | 122 | /* plugin return codes */ |
126 | enum plugin_status { | 123 | enum plugin_status { |
@@ -316,17 +313,11 @@ struct plugin_api { | |||
316 | int numberlen IF_CNFN_NUM_(, int *num)); | 313 | int numberlen IF_CNFN_NUM_(, int *num)); |
317 | 314 | ||
318 | /* dir */ | 315 | /* dir */ |
319 | DIR* (*PREFIX(opendir))(const char* name); | 316 | DIR* (*opendir)(const char* name); |
320 | int (*PREFIX(closedir))(DIR* dir); | 317 | int (*closedir)(DIR* dir); |
321 | struct dirent* (*PREFIX(readdir))(DIR* dir); | 318 | struct dirent* (*readdir)(DIR* dir); |
322 | int (*PREFIX(mkdir))(const char *name); | 319 | int (*mkdir)(const char *name); |
323 | int (*PREFIX(rmdir))(const char *name); | 320 | int (*rmdir)(const char *name); |
324 | /* dir, cached */ | ||
325 | #ifdef HAVE_DIRCACHE | ||
326 | DIRCACHED* (*opendir_cached)(const char* name); | ||
327 | struct dircache_entry* (*readdir_cached)(DIRCACHED* dir); | ||
328 | int (*closedir_cached)(DIRCACHED* dir); | ||
329 | #endif | ||
330 | 321 | ||
331 | /* kernel/ system */ | 322 | /* kernel/ system */ |
332 | void (*PREFIX(sleep))(int ticks); | 323 | void (*PREFIX(sleep))(int ticks); |
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c index 90c446b9eb..a9e348160f 100644 --- a/apps/plugins/doom/rockdoom.c +++ b/apps/plugins/doom/rockdoom.c | |||
@@ -329,7 +329,7 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory | |||
329 | char *startpt; | 329 | char *startpt; |
330 | struct menu_item *temp; | 330 | struct menu_item *temp; |
331 | 331 | ||
332 | filedir=opendir(directory); | 332 | filedir=rb->opendir(directory); |
333 | 333 | ||
334 | if(filedir==NULL) | 334 | if(filedir==NULL) |
335 | { | 335 | { |
@@ -345,8 +345,8 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory | |||
345 | i++; | 345 | i++; |
346 | 346 | ||
347 | // Reset the directory | 347 | // Reset the directory |
348 | closedir(filedir); | 348 | rb->closedir(filedir); |
349 | filedir=opendir(directory); | 349 | filedir=rb->opendir(directory); |
350 | 350 | ||
351 | i++; | 351 | i++; |
352 | temp=malloc(i*sizeof(struct opt_items)); | 352 | temp=malloc(i*sizeof(struct opt_items)); |
@@ -365,7 +365,7 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory | |||
365 | i++; | 365 | i++; |
366 | } | 366 | } |
367 | } | 367 | } |
368 | closedir(filedir); | 368 | rb->closedir(filedir); |
369 | *names=temp; | 369 | *names=temp; |
370 | return i; | 370 | return i; |
371 | } | 371 | } |
diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h index 86de4cbe13..1541ef48fd 100644 --- a/apps/plugins/doom/rockmacros.h +++ b/apps/plugins/doom/rockmacros.h | |||
@@ -40,26 +40,17 @@ char *my_strtok( char * s, const char * delim ); | |||
40 | #define read_line(a,b,c) rb->read_line((a),(b),(c)) | 40 | #define read_line(a,b,c) rb->read_line((a),(b),(c)) |
41 | 41 | ||
42 | #ifdef SIMULATOR | 42 | #ifdef SIMULATOR |
43 | #undef opendir | ||
44 | #undef closedir | ||
45 | #undef mkdir | ||
46 | #undef open | 43 | #undef open |
47 | #undef lseek | 44 | #undef lseek |
48 | #undef filesize | 45 | #undef filesize |
49 | #define opendir(a) rb->sim_opendir((a)) | ||
50 | #define closedir(a) rb->sim_closedir((a)) | ||
51 | #define mkdir(a) rb->sim_mkdir((a)) | ||
52 | #define open(a,b) rb->sim_open((a),(b)) | 46 | #define open(a,b) rb->sim_open((a),(b)) |
53 | #define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) | 47 | #define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) |
54 | #define filesize(a) rb->sim_filesize((a)) | 48 | #define filesize(a) rb->sim_filesize((a)) |
55 | #else /* !SIMULATOR */ | 49 | #else /* !SIMULATOR */ |
56 | #define opendir(a) rb->opendir((a)) | ||
57 | #define closedir(a) rb->closedir((a)) | ||
58 | #define filesize(a) rb->filesize((a)) | ||
59 | #define mkdir(a) rb->mkdir((a)) | ||
60 | #define open(a,b) my_open((a),(b)) | 50 | #define open(a,b) my_open((a),(b)) |
61 | #define close(a) my_close((a)) | 51 | #define close(a) my_close((a)) |
62 | #define lseek(a,b,c) rb->lseek((a),(b),(c)) | 52 | #define lseek(a,b,c) rb->lseek((a),(b),(c)) |
53 | #define filesize(a) rb->filesize((a)) | ||
63 | #endif /* !SIMULATOR */ | 54 | #endif /* !SIMULATOR */ |
64 | 55 | ||
65 | #define strtok(a,b) my_strtok((a),(b)) | 56 | #define strtok(a,b) my_strtok((a),(b)) |
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index 3b4f2797af..86817e2cc7 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c | |||
@@ -59,30 +59,18 @@ static bool file_properties(char* selected_file) | |||
59 | { | 59 | { |
60 | bool found = false; | 60 | bool found = false; |
61 | char tstr[MAX_PATH]; | 61 | char tstr[MAX_PATH]; |
62 | #ifdef HAVE_DIRCACHE | ||
63 | DIRCACHED* dir; | ||
64 | struct dircache_entry* entry; | ||
65 | #else | ||
66 | DIR* dir; | 62 | DIR* dir; |
67 | struct dirent* entry; | 63 | struct dirent* entry; |
68 | #endif | 64 | |
69 | char* ptr = rb->strrchr(selected_file, '/') + 1; | 65 | char* ptr = rb->strrchr(selected_file, '/') + 1; |
70 | int dirlen = (ptr - selected_file); | 66 | int dirlen = (ptr - selected_file); |
71 | rb->strncpy(tstr, selected_file, dirlen); | 67 | rb->strncpy(tstr, selected_file, dirlen); |
72 | tstr[dirlen] = 0; | 68 | tstr[dirlen] = 0; |
73 | 69 | ||
74 | #ifdef HAVE_DIRCACHE | ||
75 | dir = rb->opendir_cached(tstr); | ||
76 | #else | ||
77 | dir = rb->opendir(tstr); | 70 | dir = rb->opendir(tstr); |
78 | #endif | ||
79 | if (dir) | 71 | if (dir) |
80 | { | 72 | { |
81 | #ifdef HAVE_DIRCACHE | ||
82 | while(0 != (entry = rb->readdir_cached(dir))) | ||
83 | #else | ||
84 | while(0 != (entry = rb->readdir(dir))) | 73 | while(0 != (entry = rb->readdir(dir))) |
85 | #endif | ||
86 | { | 74 | { |
87 | if(!rb->strcmp(entry->d_name, selected_file+dirlen)) | 75 | if(!rb->strcmp(entry->d_name, selected_file+dirlen)) |
88 | { | 76 | { |
@@ -103,11 +91,7 @@ static bool file_properties(char* selected_file) | |||
103 | break; | 91 | break; |
104 | } | 92 | } |
105 | } | 93 | } |
106 | #ifdef HAVE_DIRCACHE | ||
107 | rb->closedir_cached(dir); | ||
108 | #else | ||
109 | rb->closedir(dir); | 94 | rb->closedir(dir); |
110 | #endif | ||
111 | } | 95 | } |
112 | return found; | 96 | return found; |
113 | } | 97 | } |
@@ -128,30 +112,17 @@ static bool _dir_properties(DPS* dps) | |||
128 | and informs the user of the progress */ | 112 | and informs the user of the progress */ |
129 | bool result; | 113 | bool result; |
130 | int dirlen; | 114 | int dirlen; |
131 | #ifdef HAVE_DIRCACHE | ||
132 | DIRCACHED* dir; | ||
133 | struct dircache_entry* entry; | ||
134 | #else | ||
135 | DIR* dir; | 115 | DIR* dir; |
136 | struct dirent* entry; | 116 | struct dirent* entry; |
137 | #endif | ||
138 | 117 | ||
139 | result = true; | 118 | result = true; |
140 | dirlen = rb->strlen(dps->dirname); | 119 | dirlen = rb->strlen(dps->dirname); |
141 | #ifdef HAVE_DIRCACHE | ||
142 | dir = rb->opendir_cached(dps->dirname); | ||
143 | #else | ||
144 | dir = rb->opendir(dps->dirname); | 120 | dir = rb->opendir(dps->dirname); |
145 | #endif | ||
146 | if (!dir) | 121 | if (!dir) |
147 | return false; /* open error */ | 122 | return false; /* open error */ |
148 | 123 | ||
149 | /* walk through the directory content */ | 124 | /* walk through the directory content */ |
150 | #ifdef HAVE_DIRCACHE | ||
151 | while(result && (0 != (entry = rb->readdir_cached(dir)))) | ||
152 | #else | ||
153 | while(result && (0 != (entry = rb->readdir(dir)))) | 125 | while(result && (0 != (entry = rb->readdir(dir)))) |
154 | #endif | ||
155 | { | 126 | { |
156 | /* append name to current directory */ | 127 | /* append name to current directory */ |
157 | rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s", | 128 | rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s", |
@@ -189,12 +160,7 @@ static bool _dir_properties(DPS* dps) | |||
189 | result = false; | 160 | result = false; |
190 | rb->yield(); | 161 | rb->yield(); |
191 | } | 162 | } |
192 | #ifdef HAVE_DIRCACHE | ||
193 | rb->closedir_cached(dir); | ||
194 | #else | ||
195 | rb->closedir(dir); | 163 | rb->closedir(dir); |
196 | #endif | ||
197 | |||
198 | return result; | 164 | return result; |
199 | } | 165 | } |
200 | 166 | ||
@@ -256,30 +222,17 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file) | |||
256 | 222 | ||
257 | /* determine if it's a file or a directory */ | 223 | /* determine if it's a file or a directory */ |
258 | bool found = false; | 224 | bool found = false; |
259 | #ifdef HAVE_DIRCACHE | ||
260 | DIRCACHED* dir; | ||
261 | struct dircache_entry* entry; | ||
262 | #else | ||
263 | DIR* dir; | 225 | DIR* dir; |
264 | struct dirent* entry; | 226 | struct dirent* entry; |
265 | #endif | ||
266 | char* ptr = rb->strrchr((char*)file, '/') + 1; | 227 | char* ptr = rb->strrchr((char*)file, '/') + 1; |
267 | int dirlen = (ptr - (char*)file); | 228 | int dirlen = (ptr - (char*)file); |
268 | rb->strncpy(str_dirname, (char*)file, dirlen); | 229 | rb->strncpy(str_dirname, (char*)file, dirlen); |
269 | str_dirname[dirlen] = 0; | 230 | str_dirname[dirlen] = 0; |
270 | 231 | ||
271 | #ifdef HAVE_DIRCACHE | ||
272 | dir = rb->opendir_cached(str_dirname); | ||
273 | #else | ||
274 | dir = rb->opendir(str_dirname); | 232 | dir = rb->opendir(str_dirname); |
275 | #endif | ||
276 | if (dir) | 233 | if (dir) |
277 | { | 234 | { |
278 | #ifdef HAVE_DIRCACHE | ||
279 | while(0 != (entry = rb->readdir_cached(dir))) | ||
280 | #else | ||
281 | while(0 != (entry = rb->readdir(dir))) | 235 | while(0 != (entry = rb->readdir(dir))) |
282 | #endif | ||
283 | { | 236 | { |
284 | if(!rb->strcmp(entry->d_name, file+dirlen)) | 237 | if(!rb->strcmp(entry->d_name, file+dirlen)) |
285 | { | 238 | { |
@@ -288,11 +241,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file) | |||
288 | break; | 241 | break; |
289 | } | 242 | } |
290 | } | 243 | } |
291 | #ifdef HAVE_DIRCACHE | ||
292 | rb->closedir_cached(dir); | ||
293 | #else | ||
294 | rb->closedir(dir); | 244 | rb->closedir(dir); |
295 | #endif | ||
296 | } | 245 | } |
297 | /* now we know if it's a file or a dir or maybe something failed */ | 246 | /* now we know if it's a file or a dir or maybe something failed */ |
298 | 247 | ||
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c index 46a0aa56c3..93bd98ca78 100644 --- a/apps/plugins/rockboy/rockboy.c +++ b/apps/plugins/rockboy/rockboy.c | |||
@@ -71,11 +71,11 @@ void setoptions (void) | |||
71 | DIR* dir; | 71 | DIR* dir; |
72 | char optionsave[sizeof(savedir)+sizeof(optionname)]; | 72 | char optionsave[sizeof(savedir)+sizeof(optionname)]; |
73 | 73 | ||
74 | dir=opendir(savedir); | 74 | dir=rb->opendir(savedir); |
75 | if(!dir) | 75 | if(!dir) |
76 | mkdir(savedir); | 76 | rb->mkdir(savedir); |
77 | else | 77 | else |
78 | closedir(dir); | 78 | rb->closedir(dir); |
79 | 79 | ||
80 | snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); | 80 | snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); |
81 | 81 | ||
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h index ecf8a1ef6a..5d60d3f3e3 100644 --- a/apps/plugins/rockboy/rockmacros.h +++ b/apps/plugins/rockboy/rockmacros.h | |||
@@ -71,22 +71,13 @@ void dynamic_recompile (struct dynarec_block *newblock); | |||
71 | #define isalnum(c) (isdigit(c) || (isalpha(c))) | 71 | #define isalnum(c) (isdigit(c) || (isalpha(c))) |
72 | 72 | ||
73 | #ifdef SIMULATOR | 73 | #ifdef SIMULATOR |
74 | #undef opendir | ||
75 | #define opendir(a) rb->sim_opendir((a)) | ||
76 | #undef closedir | ||
77 | #define closedir(a) rb->sim_closedir((a)) | ||
78 | #undef mkdir | ||
79 | #define mkdir(a) rb->sim_mkdir((a)) | ||
80 | #undef open | 74 | #undef open |
81 | #define open(a,b) rb->sim_open((a),(b)) | 75 | #define open(a,b) rb->sim_open((a),(b)) |
82 | #undef close | ||
83 | #define close(a) rb->close((a)) | ||
84 | #undef lseek | 76 | #undef lseek |
85 | #define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) | 77 | #define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) |
78 | #undef close | ||
79 | #define close(a) rb->close((a)) | ||
86 | #else /* !SIMULATOR */ | 80 | #else /* !SIMULATOR */ |
87 | #define opendir(a) rb->opendir((a)) | ||
88 | #define closedir(a) rb->closedir((a)) | ||
89 | #define mkdir(a) rb->mkdir((a)) | ||
90 | #define open(a,b) rb->open((a),(b)) | 81 | #define open(a,b) rb->open((a),(b)) |
91 | #define lseek(a,b,c) rb->lseek((a),(b),(c)) | 82 | #define lseek(a,b,c) rb->lseek((a),(b),(c)) |
92 | #define close(a) rb->close((a)) | 83 | #define close(a) rb->close((a)) |
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index d478bf9947..a273e4ca37 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c | |||
@@ -688,7 +688,7 @@ static bool browse( char *dst, int dst_size, const char *start ) | |||
688 | 688 | ||
689 | while( 1 ) | 689 | while( 1 ) |
690 | { | 690 | { |
691 | d = rb->PREFIX(opendir)( bbuf ); | 691 | d = rb->opendir( bbuf ); |
692 | if( !d ) | 692 | if( !d ) |
693 | { | 693 | { |
694 | /* | 694 | /* |
@@ -702,7 +702,7 @@ static bool browse( char *dst, int dst_size, const char *start ) | |||
702 | else if( errno == EACCES || errno == ENOENT ) | 702 | else if( errno == EACCES || errno == ENOENT ) |
703 | { | 703 | { |
704 | bbuf[0] = '/'; bbuf[1] = '\0'; | 704 | bbuf[0] = '/'; bbuf[1] = '\0'; |
705 | d = rb->PREFIX(opendir)( "/" ); | 705 | d = rb->opendir( "/" ); |
706 | } | 706 | } |
707 | else | 707 | else |
708 | { | 708 | { |
@@ -714,12 +714,12 @@ static bool browse( char *dst, int dst_size, const char *start ) | |||
714 | li = -1; | 714 | li = -1; |
715 | while( i < fvi ) | 715 | while( i < fvi ) |
716 | { | 716 | { |
717 | rb->PREFIX(readdir)( d ); | 717 | rb->readdir( d ); |
718 | i++; | 718 | i++; |
719 | } | 719 | } |
720 | while( top_inside+(i-fvi)*(fh+LINE_SPACE) < HEIGHT ) | 720 | while( top_inside+(i-fvi)*(fh+LINE_SPACE) < HEIGHT ) |
721 | { | 721 | { |
722 | de = rb->PREFIX(readdir)( d ); | 722 | de = rb->readdir( d ); |
723 | if( !de ) | 723 | if( !de ) |
724 | { | 724 | { |
725 | li = i-1; | 725 | li = i-1; |
@@ -737,12 +737,12 @@ static bool browse( char *dst, int dst_size, const char *start ) | |||
737 | lvi = i-1; | 737 | lvi = i-1; |
738 | if( li == -1 ) | 738 | if( li == -1 ) |
739 | { | 739 | { |
740 | if( !rb->PREFIX(readdir)( d ) ) | 740 | if( !rb->readdir( d ) ) |
741 | { | 741 | { |
742 | li = lvi; | 742 | li = lvi; |
743 | } | 743 | } |
744 | } | 744 | } |
745 | rb->PREFIX(closedir)( d ); | 745 | rb->closedir( d ); |
746 | 746 | ||
747 | rb->lcd_update(); | 747 | rb->lcd_update(); |
748 | 748 | ||
@@ -863,7 +863,7 @@ static bool browse_fonts( char *dst, int dst_size ) | |||
863 | { | 863 | { |
864 | b_need_redraw = 0; | 864 | b_need_redraw = 0; |
865 | 865 | ||
866 | d = rb->PREFIX(opendir)( FONT_DIR "/" ); | 866 | d = rb->opendir( FONT_DIR "/" ); |
867 | if( !d ) | 867 | if( !d ) |
868 | { | 868 | { |
869 | return false; | 869 | return false; |
@@ -873,7 +873,7 @@ static bool browse_fonts( char *dst, int dst_size ) | |||
873 | li = -1; | 873 | li = -1; |
874 | while( i < fvi ) | 874 | while( i < fvi ) |
875 | { | 875 | { |
876 | rb->PREFIX(readdir)( d ); | 876 | rb->readdir( d ); |
877 | i++; | 877 | i++; |
878 | } | 878 | } |
879 | cp = top_inside+LINE_SPACE; | 879 | cp = top_inside+LINE_SPACE; |
@@ -883,7 +883,7 @@ static bool browse_fonts( char *dst, int dst_size ) | |||
883 | 883 | ||
884 | while( cp < top+HEIGHT ) | 884 | while( cp < top+HEIGHT ) |
885 | { | 885 | { |
886 | de = rb->PREFIX(readdir)( d ); | 886 | de = rb->readdir( d ); |
887 | if( !de ) | 887 | if( !de ) |
888 | { | 888 | { |
889 | li = i-1; | 889 | li = i-1; |
@@ -920,7 +920,7 @@ static bool browse_fonts( char *dst, int dst_size ) | |||
920 | lvi = i-1; | 920 | lvi = i-1; |
921 | if( li == -1 ) | 921 | if( li == -1 ) |
922 | { | 922 | { |
923 | if( !(de = rb->PREFIX(readdir)( d ) ) ) | 923 | if( !(de = rb->readdir( d ) ) ) |
924 | { | 924 | { |
925 | li = lvi; | 925 | li = lvi; |
926 | } | 926 | } |
@@ -936,7 +936,7 @@ static bool browse_fonts( char *dst, int dst_size ) | |||
936 | } | 936 | } |
937 | } | 937 | } |
938 | rb->font_load( old_font ); | 938 | rb->font_load( old_font ); |
939 | rb->PREFIX(closedir)( d ); | 939 | rb->closedir( d ); |
940 | } | 940 | } |
941 | 941 | ||
942 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | 942 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); |
diff --git a/apps/tagcache.c b/apps/tagcache.c index 41138ddf2c..f832f1e543 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -70,7 +70,7 @@ | |||
70 | #include "crc32.h" | 70 | #include "crc32.h" |
71 | #include "misc.h" | 71 | #include "misc.h" |
72 | #include "settings.h" | 72 | #include "settings.h" |
73 | #include "dircache.h" | 73 | #include "dir.h" |
74 | #include "structec.h" | 74 | #include "structec.h" |
75 | #ifndef __PCTOOL__ | 75 | #ifndef __PCTOOL__ |
76 | #include "atoi.h" | 76 | #include "atoi.h" |
@@ -327,7 +327,7 @@ static bool do_timed_yield(void) | |||
327 | 327 | ||
328 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) | 328 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) |
329 | static long find_entry_ram(const char *filename, | 329 | static long find_entry_ram(const char *filename, |
330 | const struct dircache_entry *dc) | 330 | const struct dirent *dc) |
331 | { | 331 | { |
332 | static long last_pos = 0; | 332 | static long last_pos = 0; |
333 | int i; | 333 | int i; |
@@ -626,7 +626,7 @@ static bool retrieve(struct tagcache_search *tcs, struct index_entry *idx, | |||
626 | # ifdef HAVE_DIRCACHE | 626 | # ifdef HAVE_DIRCACHE |
627 | if (tag == tag_filename && idx->flag & FLAG_DIRCACHE) | 627 | if (tag == tag_filename && idx->flag & FLAG_DIRCACHE) |
628 | { | 628 | { |
629 | dircache_copy_path((struct dircache_entry *)seek, | 629 | dircache_copy_path((struct dirent *)seek, |
630 | buf, size); | 630 | buf, size); |
631 | return true; | 631 | return true; |
632 | } | 632 | } |
@@ -1329,7 +1329,7 @@ static bool get_next(struct tagcache_search *tcs) | |||
1329 | # ifdef HAVE_DIRCACHE | 1329 | # ifdef HAVE_DIRCACHE |
1330 | if (tcs->type == tag_filename) | 1330 | if (tcs->type == tag_filename) |
1331 | { | 1331 | { |
1332 | dircache_copy_path((struct dircache_entry *)tcs->position, | 1332 | dircache_copy_path((struct dirent *)tcs->position, |
1333 | buf, sizeof buf); | 1333 | buf, sizeof buf); |
1334 | tcs->result = buf; | 1334 | tcs->result = buf; |
1335 | tcs->result_len = strlen(buf) + 1; | 1335 | tcs->result_len = strlen(buf) + 1; |
@@ -1583,7 +1583,7 @@ static int check_if_empty(char **tag) | |||
1583 | offset += entry.tag_length[tag] | 1583 | offset += entry.tag_length[tag] |
1584 | 1584 | ||
1585 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) | 1585 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) |
1586 | static void add_tagcache(char *path, const struct dircache_entry *dc) | 1586 | static void add_tagcache(char *path, const struct dirent *dc) |
1587 | #else | 1587 | #else |
1588 | static void add_tagcache(char *path) | 1588 | static void add_tagcache(char *path) |
1589 | #endif | 1589 | #endif |
@@ -3464,7 +3464,7 @@ static bool load_tagcache(void) | |||
3464 | if (tag == tag_filename) | 3464 | if (tag == tag_filename) |
3465 | { | 3465 | { |
3466 | # ifdef HAVE_DIRCACHE | 3466 | # ifdef HAVE_DIRCACHE |
3467 | const struct dircache_entry *dc; | 3467 | const struct dirent *dc; |
3468 | # endif | 3468 | # endif |
3469 | 3469 | ||
3470 | // FIXME: This is wrong! | 3470 | // FIXME: This is wrong! |
@@ -3647,14 +3647,14 @@ static bool check_deleted_files(void) | |||
3647 | 3647 | ||
3648 | static bool check_dir(const char *dirname) | 3648 | static bool check_dir(const char *dirname) |
3649 | { | 3649 | { |
3650 | DIRCACHED *dir; | 3650 | DIR *dir; |
3651 | int len; | 3651 | int len; |
3652 | int success = false; | 3652 | int success = false; |
3653 | 3653 | ||
3654 | dir = opendir_cached(dirname); | 3654 | dir = opendir(dirname); |
3655 | if (!dir) | 3655 | if (!dir) |
3656 | { | 3656 | { |
3657 | logf("tagcache: opendir_cached() failed"); | 3657 | logf("tagcache: opendir() failed"); |
3658 | return false; | 3658 | return false; |
3659 | } | 3659 | } |
3660 | 3660 | ||
@@ -3665,9 +3665,9 @@ static bool check_dir(const char *dirname) | |||
3665 | while (!check_event_queue()) | 3665 | while (!check_event_queue()) |
3666 | #endif | 3666 | #endif |
3667 | { | 3667 | { |
3668 | struct dircache_entry *entry; | 3668 | struct dirent *entry; |
3669 | 3669 | ||
3670 | entry = readdir_cached(dir); | 3670 | entry = readdir(dir); |
3671 | 3671 | ||
3672 | if (entry == NULL) | 3672 | if (entry == NULL) |
3673 | { | 3673 | { |
@@ -3698,7 +3698,7 @@ static bool check_dir(const char *dirname) | |||
3698 | curpath[len] = '\0'; | 3698 | curpath[len] = '\0'; |
3699 | } | 3699 | } |
3700 | 3700 | ||
3701 | closedir_cached(dir); | 3701 | closedir(dir); |
3702 | 3702 | ||
3703 | return success; | 3703 | return success; |
3704 | } | 3704 | } |
diff --git a/apps/tree.c b/apps/tree.c index b54238b08c..ccdbd69d0a 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -931,20 +931,20 @@ static long pltick; | |||
931 | static bool add_dir(char* dirname, int len, int fd) | 931 | static bool add_dir(char* dirname, int len, int fd) |
932 | { | 932 | { |
933 | bool abort = false; | 933 | bool abort = false; |
934 | DIRCACHED* dir; | 934 | DIR* dir; |
935 | 935 | ||
936 | /* check for user abort */ | 936 | /* check for user abort */ |
937 | if (action_userabort(TIMEOUT_NOBLOCK)) | 937 | if (action_userabort(TIMEOUT_NOBLOCK)) |
938 | return true; | 938 | return true; |
939 | 939 | ||
940 | dir = opendir_cached(dirname); | 940 | dir = opendir(dirname); |
941 | if(!dir) | 941 | if(!dir) |
942 | return true; | 942 | return true; |
943 | 943 | ||
944 | while (true) { | 944 | while (true) { |
945 | struct dircache_entry *entry; | 945 | struct dirent *entry; |
946 | 946 | ||
947 | entry = readdir_cached(dir); | 947 | entry = readdir(dir); |
948 | if (!entry) | 948 | if (!entry) |
949 | break; | 949 | break; |
950 | if (entry->attribute & ATTR_DIRECTORY) { | 950 | if (entry->attribute & ATTR_DIRECTORY) { |
@@ -1021,7 +1021,7 @@ static bool add_dir(char* dirname, int len, int fd) | |||
1021 | } | 1021 | } |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | closedir_cached(dir); | 1024 | closedir(dir); |
1025 | 1025 | ||
1026 | return abort; | 1026 | return abort; |
1027 | } | 1027 | } |
diff --git a/firmware/SOURCES b/firmware/SOURCES index d899551a37..6e7762ac75 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -28,7 +28,7 @@ common/crc32-mi4.c | |||
28 | #endif | 28 | #endif |
29 | common/ctype.c | 29 | common/ctype.c |
30 | #ifndef SIMULATOR | 30 | #ifndef SIMULATOR |
31 | common/dir.c | 31 | common/dir_uncached.c |
32 | common/file.c | 32 | common/file.c |
33 | #endif /* SIMULATOR */ | 33 | #endif /* SIMULATOR */ |
34 | #ifdef HAVE_DIRCACHE | 34 | #ifdef HAVE_DIRCACHE |
diff --git a/firmware/common/dir.c b/firmware/common/dir_uncached.c index 0f46652b3c..e6b59c30ec 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir_uncached.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id: dir.c 13741 2007-06-30 02:08:27Z jethead71 $ |
9 | * | 9 | * |
10 | * Copyright (C) 2002 by Björn Stenberg | 10 | * Copyright (C) 2002 by Björn Stenberg |
11 | * | 11 | * |
@@ -24,11 +24,11 @@ | |||
24 | #include "dir.h" | 24 | #include "dir.h" |
25 | #include "debug.h" | 25 | #include "debug.h" |
26 | #include "atoi.h" | 26 | #include "atoi.h" |
27 | #include "dircache.h" | 27 | //#include "dircache.h" |
28 | 28 | ||
29 | #define MAX_OPEN_DIRS 8 | 29 | #define MAX_OPEN_DIRS 8 |
30 | 30 | ||
31 | static DIR opendirs[MAX_OPEN_DIRS]; | 31 | static DIR_UNCACHED opendirs[MAX_OPEN_DIRS]; |
32 | 32 | ||
33 | #ifdef HAVE_MULTIVOLUME | 33 | #ifdef HAVE_MULTIVOLUME |
34 | 34 | ||
@@ -78,7 +78,7 @@ static int strip_volume(const char* name, char* namecopy) | |||
78 | // release all dir handles on a given volume "by force", to avoid leaks | 78 | // release all dir handles on a given volume "by force", to avoid leaks |
79 | int release_dirs(int volume) | 79 | int release_dirs(int volume) |
80 | { | 80 | { |
81 | DIR* pdir = opendirs; | 81 | DIR_UNCACHED* pdir = opendirs; |
82 | int dd; | 82 | int dd; |
83 | int closed = 0; | 83 | int closed = 0; |
84 | for ( dd=0; dd<MAX_OPEN_DIRS; dd++, pdir++) | 84 | for ( dd=0; dd<MAX_OPEN_DIRS; dd++, pdir++) |
@@ -93,14 +93,14 @@ int release_dirs(int volume) | |||
93 | } | 93 | } |
94 | #endif /* #ifdef HAVE_HOTSWAP */ | 94 | #endif /* #ifdef HAVE_HOTSWAP */ |
95 | 95 | ||
96 | DIR* opendir(const char* name) | 96 | DIR_UNCACHED* opendir_uncached(const char* name) |
97 | { | 97 | { |
98 | char namecopy[MAX_PATH]; | 98 | char namecopy[MAX_PATH]; |
99 | char* part; | 99 | char* part; |
100 | char* end; | 100 | char* end; |
101 | struct fat_direntry entry; | 101 | struct fat_direntry entry; |
102 | int dd; | 102 | int dd; |
103 | DIR* pdir = opendirs; | 103 | DIR_UNCACHED* pdir = opendirs; |
104 | #ifdef HAVE_MULTIVOLUME | 104 | #ifdef HAVE_MULTIVOLUME |
105 | int volume; | 105 | int volume; |
106 | #endif | 106 | #endif |
@@ -170,16 +170,16 @@ DIR* opendir(const char* name) | |||
170 | return pdir; | 170 | return pdir; |
171 | } | 171 | } |
172 | 172 | ||
173 | int closedir(DIR* dir) | 173 | int closedir_uncached(DIR_UNCACHED* dir) |
174 | { | 174 | { |
175 | dir->busy=false; | 175 | dir->busy=false; |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | struct dirent* readdir(DIR* dir) | 179 | struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir) |
180 | { | 180 | { |
181 | struct fat_direntry entry; | 181 | struct fat_direntry entry; |
182 | struct dirent* theent = &(dir->theent); | 182 | struct dirent_uncached* theent = &(dir->theent); |
183 | 183 | ||
184 | if (!dir->busy) | 184 | if (!dir->busy) |
185 | return NULL; | 185 | return NULL; |
@@ -191,7 +191,7 @@ struct dirent* readdir(DIR* dir) | |||
191 | && dir->volumecounter < NUM_VOLUMES /* in range */ | 191 | && dir->volumecounter < NUM_VOLUMES /* in range */ |
192 | && dir->fatdir.file.volume == 0) /* at volume 0 */ | 192 | && dir->fatdir.file.volume == 0) /* at volume 0 */ |
193 | { /* fake special directories, which don't really exist, but | 193 | { /* fake special directories, which don't really exist, but |
194 | will get redirected upon opendir() */ | 194 | will get redirected upon opendir_uncached() */ |
195 | while (++dir->volumecounter < NUM_VOLUMES) | 195 | while (++dir->volumecounter < NUM_VOLUMES) |
196 | { | 196 | { |
197 | if (fat_ismounted(dir->volumecounter)) | 197 | if (fat_ismounted(dir->volumecounter)) |
@@ -222,14 +222,14 @@ struct dirent* readdir(DIR* dir) | |||
222 | return theent; | 222 | return theent; |
223 | } | 223 | } |
224 | 224 | ||
225 | int mkdir(const char *name) | 225 | int mkdir_uncached(const char *name) |
226 | { | 226 | { |
227 | DIR *dir; | 227 | DIR_UNCACHED *dir; |
228 | char namecopy[MAX_PATH]; | 228 | char namecopy[MAX_PATH]; |
229 | char* end; | 229 | char* end; |
230 | char *basename; | 230 | char *basename; |
231 | char *parent; | 231 | char *parent; |
232 | struct dirent *entry; | 232 | struct dirent_uncached *entry; |
233 | struct fat_dir newdir; | 233 | struct fat_dir newdir; |
234 | int rc; | 234 | int rc; |
235 | 235 | ||
@@ -253,7 +253,7 @@ int mkdir(const char *name) | |||
253 | 253 | ||
254 | DEBUGF("mkdir: parent: %s, name: %s\n", parent, basename); | 254 | DEBUGF("mkdir: parent: %s, name: %s\n", parent, basename); |
255 | 255 | ||
256 | dir = opendir(parent); | 256 | dir = opendir_uncached(parent); |
257 | 257 | ||
258 | if(!dir) { | 258 | if(!dir) { |
259 | DEBUGF("mkdir: can't open parent dir\n"); | 259 | DEBUGF("mkdir: can't open parent dir\n"); |
@@ -267,11 +267,11 @@ int mkdir(const char *name) | |||
267 | } | 267 | } |
268 | 268 | ||
269 | /* Now check if the name already exists */ | 269 | /* Now check if the name already exists */ |
270 | while ((entry = readdir(dir))) { | 270 | while ((entry = readdir_uncached(dir))) { |
271 | if ( !strcasecmp(basename, entry->d_name) ) { | 271 | if ( !strcasecmp(basename, entry->d_name) ) { |
272 | DEBUGF("mkdir error: file exists\n"); | 272 | DEBUGF("mkdir error: file exists\n"); |
273 | errno = EEXIST; | 273 | errno = EEXIST; |
274 | closedir(dir); | 274 | closedir_uncached(dir); |
275 | return - 4; | 275 | return - 4; |
276 | } | 276 | } |
277 | } | 277 | } |
@@ -279,23 +279,18 @@ int mkdir(const char *name) | |||
279 | memset(&newdir, sizeof(struct fat_dir), 0); | 279 | memset(&newdir, sizeof(struct fat_dir), 0); |
280 | 280 | ||
281 | rc = fat_create_dir(basename, &newdir, &(dir->fatdir)); | 281 | rc = fat_create_dir(basename, &newdir, &(dir->fatdir)); |
282 | #ifdef HAVE_DIRCACHE | 282 | closedir_uncached(dir); |
283 | if (rc >= 0) | ||
284 | dircache_mkdir(name); | ||
285 | #endif | ||
286 | |||
287 | closedir(dir); | ||
288 | 283 | ||
289 | return rc; | 284 | return rc; |
290 | } | 285 | } |
291 | 286 | ||
292 | int rmdir(const char* name) | 287 | int rmdir_uncached(const char* name) |
293 | { | 288 | { |
294 | int rc; | 289 | int rc; |
295 | DIR* dir; | 290 | DIR_UNCACHED* dir; |
296 | struct dirent* entry; | 291 | struct dirent_uncached* entry; |
297 | 292 | ||
298 | dir = opendir(name); | 293 | dir = opendir_uncached(name); |
299 | if (!dir) | 294 | if (!dir) |
300 | { | 295 | { |
301 | errno = ENOENT; /* open error */ | 296 | errno = ENOENT; /* open error */ |
@@ -303,14 +298,14 @@ int rmdir(const char* name) | |||
303 | } | 298 | } |
304 | 299 | ||
305 | /* check if the directory is empty */ | 300 | /* check if the directory is empty */ |
306 | while ((entry = readdir(dir))) | 301 | while ((entry = readdir_uncached(dir))) |
307 | { | 302 | { |
308 | if (strcmp(entry->d_name, ".") && | 303 | if (strcmp(entry->d_name, ".") && |
309 | strcmp(entry->d_name, "..")) | 304 | strcmp(entry->d_name, "..")) |
310 | { | 305 | { |
311 | DEBUGF("rmdir error: not empty\n"); | 306 | DEBUGF("rmdir error: not empty\n"); |
312 | errno = ENOTEMPTY; | 307 | errno = ENOTEMPTY; |
313 | closedir(dir); | 308 | closedir_uncached(dir); |
314 | return -2; | 309 | return -2; |
315 | } | 310 | } |
316 | } | 311 | } |
@@ -321,14 +316,7 @@ int rmdir(const char* name) | |||
321 | errno = EIO; | 316 | errno = EIO; |
322 | rc = rc * 10 - 3; | 317 | rc = rc * 10 - 3; |
323 | } | 318 | } |
324 | #ifdef HAVE_DIRCACHE | ||
325 | else | ||
326 | { | ||
327 | dircache_rmdir(name); | ||
328 | } | ||
329 | #endif | ||
330 | 319 | ||
331 | closedir(dir); | 320 | closedir_uncached(dir); |
332 | |||
333 | return rc; | 321 | return rc; |
334 | } | 322 | } |
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index be356e1ddf..97c58842d5 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | #include <string.h> | 28 | #include <string.h> |
29 | #include <stdbool.h> | 29 | #include <stdbool.h> |
30 | #include "dir.h" | ||
31 | #include "debug.h" | 30 | #include "debug.h" |
32 | #include "atoi.h" | 31 | #include "atoi.h" |
33 | #include "system.h" | 32 | #include "system.h" |
@@ -44,7 +43,7 @@ | |||
44 | #define DIRCACHE_STOP 2 | 43 | #define DIRCACHE_STOP 2 |
45 | 44 | ||
46 | #define MAX_OPEN_DIRS 8 | 45 | #define MAX_OPEN_DIRS 8 |
47 | DIRCACHED opendirs[MAX_OPEN_DIRS]; | 46 | DIR_CACHED opendirs[MAX_OPEN_DIRS]; |
48 | 47 | ||
49 | static struct dircache_entry *fd_bindings[MAX_OPEN_FILES]; | 48 | static struct dircache_entry *fd_bindings[MAX_OPEN_FILES]; |
50 | static struct dircache_entry *dircache_root; | 49 | static struct dircache_entry *dircache_root; |
@@ -165,7 +164,7 @@ static bool check_event_queue(void) | |||
165 | static int dircache_scan(struct travel_data *td) | 164 | static int dircache_scan(struct travel_data *td) |
166 | { | 165 | { |
167 | #ifdef SIMULATOR | 166 | #ifdef SIMULATOR |
168 | while ( ( td->entry = readdir(td->dir) ) ) | 167 | while ( ( td->entry = readdir_uncached(td->dir) ) ) |
169 | #else | 168 | #else |
170 | while ( (fat_getnext(td->dir, &td->entry) >= 0) && (td->entry.name[0])) | 169 | while ( (fat_getnext(td->dir, &td->entry) >= 0) && (td->entry.name[0])) |
171 | #endif | 170 | #endif |
@@ -221,10 +220,10 @@ static int dircache_scan(struct travel_data *td) | |||
221 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry->d_name, | 220 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry->d_name, |
222 | sizeof(dircache_cur_path) - td->pathpos - 2); | 221 | sizeof(dircache_cur_path) - td->pathpos - 2); |
223 | 222 | ||
224 | td->newdir = opendir(dircache_cur_path); | 223 | td->newdir = opendir_uncached(dircache_cur_path); |
225 | if (td->newdir == NULL) | 224 | if (td->newdir == NULL) |
226 | { | 225 | { |
227 | logf("Failed to opendir(): %s", dircache_cur_path); | 226 | logf("Failed to opendir_uncached(): %s", dircache_cur_path); |
228 | return -3; | 227 | return -3; |
229 | } | 228 | } |
230 | #else | 229 | #else |
@@ -269,7 +268,7 @@ static int dircache_scan(struct travel_data *td) | |||
269 | * Recursively scan the hard disk and build the cache. | 268 | * Recursively scan the hard disk and build the cache. |
270 | */ | 269 | */ |
271 | #ifdef SIMULATOR | 270 | #ifdef SIMULATOR |
272 | static int dircache_travel(DIR *dir, struct dircache_entry *ce) | 271 | static int dircache_travel(DIR_UNCACHED *dir, struct dircache_entry *ce) |
273 | #else | 272 | #else |
274 | static int dircache_travel(struct fat_dir *dir, struct dircache_entry *ce) | 273 | static int dircache_travel(struct fat_dir *dir, struct dircache_entry *ce) |
275 | #endif | 274 | #endif |
@@ -292,7 +291,7 @@ static int dircache_travel(struct fat_dir *dir, struct dircache_entry *ce) | |||
292 | ce->d_name = "."; | 291 | ce->d_name = "."; |
293 | ce->name_len = 2; | 292 | ce->name_len = 2; |
294 | #ifdef SIMULATOR | 293 | #ifdef SIMULATOR |
295 | closedir(dir_recursion[depth].dir); | 294 | closedir_uncached(dir_recursion[depth].dir); |
296 | ce->attribute = ATTR_DIRECTORY; | 295 | ce->attribute = ATTR_DIRECTORY; |
297 | #else | 296 | #else |
298 | ce->attribute = FAT_ATTR_DIRECTORY; | 297 | ce->attribute = FAT_ATTR_DIRECTORY; |
@@ -519,7 +518,7 @@ int dircache_save(void) | |||
519 | static int dircache_do_rebuild(void) | 518 | static int dircache_do_rebuild(void) |
520 | { | 519 | { |
521 | #ifdef SIMULATOR | 520 | #ifdef SIMULATOR |
522 | DIR *pdir; | 521 | DIR_UNCACHED *pdir; |
523 | #else | 522 | #else |
524 | struct fat_dir dir, *pdir; | 523 | struct fat_dir dir, *pdir; |
525 | #endif | 524 | #endif |
@@ -532,7 +531,7 @@ static int dircache_do_rebuild(void) | |||
532 | dircache_initializing = true; | 531 | dircache_initializing = true; |
533 | 532 | ||
534 | #ifdef SIMULATOR | 533 | #ifdef SIMULATOR |
535 | pdir = opendir("/"); | 534 | pdir = opendir_uncached("/"); |
536 | if (pdir == NULL) | 535 | if (pdir == NULL) |
537 | { | 536 | { |
538 | logf("Failed to open rootdir"); | 537 | logf("Failed to open rootdir"); |
@@ -1082,11 +1081,11 @@ void dircache_add_file(const char *path, long startcluster) | |||
1082 | entry->startcluster = startcluster; | 1081 | entry->startcluster = startcluster; |
1083 | } | 1082 | } |
1084 | 1083 | ||
1085 | DIRCACHED* opendir_cached(const char* name) | 1084 | DIR_CACHED* opendir_cached(const char* name) |
1086 | { | 1085 | { |
1087 | struct dircache_entry *cache_entry; | 1086 | struct dircache_entry *cache_entry; |
1088 | int dd; | 1087 | int dd; |
1089 | DIRCACHED* pdir = opendirs; | 1088 | DIR_CACHED* pdir = opendirs; |
1090 | 1089 | ||
1091 | if ( name[0] != '/' ) | 1090 | if ( name[0] != '/' ) |
1092 | { | 1091 | { |
@@ -1108,7 +1107,7 @@ DIRCACHED* opendir_cached(const char* name) | |||
1108 | 1107 | ||
1109 | if (!dircache_initialized) | 1108 | if (!dircache_initialized) |
1110 | { | 1109 | { |
1111 | pdir->regulardir = opendir(name); | 1110 | pdir->regulardir = opendir_uncached(name); |
1112 | if (!pdir->regulardir) | 1111 | if (!pdir->regulardir) |
1113 | return NULL; | 1112 | return NULL; |
1114 | 1113 | ||
@@ -1130,9 +1129,9 @@ DIRCACHED* opendir_cached(const char* name) | |||
1130 | return pdir; | 1129 | return pdir; |
1131 | } | 1130 | } |
1132 | 1131 | ||
1133 | struct dircache_entry* readdir_cached(DIRCACHED* dir) | 1132 | struct dircache_entry* readdir_cached(DIR_CACHED* dir) |
1134 | { | 1133 | { |
1135 | struct dirent *regentry; | 1134 | struct dirent_uncached *regentry; |
1136 | struct dircache_entry *ce; | 1135 | struct dircache_entry *ce; |
1137 | 1136 | ||
1138 | if (!dir->busy) | 1137 | if (!dir->busy) |
@@ -1140,7 +1139,7 @@ struct dircache_entry* readdir_cached(DIRCACHED* dir) | |||
1140 | 1139 | ||
1141 | if (dir->regulardir != NULL) | 1140 | if (dir->regulardir != NULL) |
1142 | { | 1141 | { |
1143 | regentry = readdir(dir->regulardir); | 1142 | regentry = readdir_uncached(dir->regulardir); |
1144 | if (regentry == NULL) | 1143 | if (regentry == NULL) |
1145 | return NULL; | 1144 | return NULL; |
1146 | 1145 | ||
@@ -1181,15 +1180,30 @@ struct dircache_entry* readdir_cached(DIRCACHED* dir) | |||
1181 | return &dir->secondary_entry; | 1180 | return &dir->secondary_entry; |
1182 | } | 1181 | } |
1183 | 1182 | ||
1184 | int closedir_cached(DIRCACHED* dir) | 1183 | int closedir_cached(DIR_CACHED* dir) |
1185 | { | 1184 | { |
1186 | if (!dir->busy) | 1185 | if (!dir->busy) |
1187 | return -1; | 1186 | return -1; |
1188 | 1187 | ||
1189 | dir->busy=false; | 1188 | dir->busy=false; |
1190 | if (dir->regulardir != NULL) | 1189 | if (dir->regulardir != NULL) |
1191 | return closedir(dir->regulardir); | 1190 | return closedir_uncached(dir->regulardir); |
1192 | 1191 | ||
1193 | return 0; | 1192 | return 0; |
1194 | } | 1193 | } |
1195 | 1194 | ||
1195 | int mkdir_cached(const char *name) | ||
1196 | { | ||
1197 | int rc=mkdir_uncached(name); | ||
1198 | if (rc >= 0) | ||
1199 | dircache_mkdir(name); | ||
1200 | return(rc); | ||
1201 | } | ||
1202 | |||
1203 | int rmdir_cached(const char* name) | ||
1204 | { | ||
1205 | int rc=rmdir_uncached(name); | ||
1206 | if(rc>=0) | ||
1207 | dircache_rmdir(name); | ||
1208 | return(rc); | ||
1209 | } | ||
diff --git a/firmware/common/disk.c b/firmware/common/disk.c index f491c9b26a..563bb05ec1 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c | |||
@@ -22,9 +22,9 @@ | |||
22 | #include "fat.h" | 22 | #include "fat.h" |
23 | #ifdef HAVE_HOTSWAP | 23 | #ifdef HAVE_HOTSWAP |
24 | #include "hotswap.h" | 24 | #include "hotswap.h" |
25 | #include "dir.h" /* for release_dirs() */ | ||
26 | #include "file.h" /* for release_files() */ | ||
25 | #endif | 27 | #endif |
26 | #include "file.h" /* for release_dirs() */ | ||
27 | #include "dir.h" /* for release_files() */ | ||
28 | #include "disk.h" | 28 | #include "disk.h" |
29 | 29 | ||
30 | /* Partition table entry layout: | 30 | /* Partition table entry layout: |
diff --git a/firmware/common/file.c b/firmware/common/file.c index bc57d556b3..d526f28859 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
22 | #include "file.h" | 22 | #include "file.h" |
23 | #include "fat.h" | 23 | #include "fat.h" |
24 | #include "dir.h" | 24 | #include "dir_uncached.h" |
25 | #include "debug.h" | 25 | #include "debug.h" |
26 | #include "dircache.h" | 26 | #include "dircache.h" |
27 | #include "system.h" | 27 | #include "system.h" |
@@ -59,8 +59,8 @@ int creat(const char *pathname) | |||
59 | 59 | ||
60 | static int open_internal(const char* pathname, int flags, bool use_cache) | 60 | static int open_internal(const char* pathname, int flags, bool use_cache) |
61 | { | 61 | { |
62 | DIR* dir; | 62 | DIR_UNCACHED* dir; |
63 | struct dirent* entry; | 63 | struct dirent_uncached* entry; |
64 | int fd; | 64 | int fd; |
65 | char pathnamecopy[MAX_PATH]; | 65 | char pathnamecopy[MAX_PATH]; |
66 | char* name; | 66 | char* name; |
@@ -134,12 +134,12 @@ static int open_internal(const char* pathname, int flags, bool use_cache) | |||
134 | name=strrchr(pathnamecopy+1,'/'); | 134 | name=strrchr(pathnamecopy+1,'/'); |
135 | if ( name ) { | 135 | if ( name ) { |
136 | *name = 0; | 136 | *name = 0; |
137 | dir = opendir(pathnamecopy); | 137 | dir = opendir_uncached(pathnamecopy); |
138 | *name = '/'; | 138 | *name = '/'; |
139 | name++; | 139 | name++; |
140 | } | 140 | } |
141 | else { | 141 | else { |
142 | dir = opendir("/"); | 142 | dir = opendir_uncached("/"); |
143 | name = pathnamecopy+1; | 143 | name = pathnamecopy+1; |
144 | } | 144 | } |
145 | if (!dir) { | 145 | if (!dir) { |
@@ -153,12 +153,12 @@ static int open_internal(const char* pathname, int flags, bool use_cache) | |||
153 | DEBUGF("Empty file name\n"); | 153 | DEBUGF("Empty file name\n"); |
154 | errno = EINVAL; | 154 | errno = EINVAL; |
155 | file->busy = false; | 155 | file->busy = false; |
156 | closedir(dir); | 156 | closedir_uncached(dir); |
157 | return -5; | 157 | return -5; |
158 | } | 158 | } |
159 | 159 | ||
160 | /* scan dir for name */ | 160 | /* scan dir for name */ |
161 | while ((entry = readdir(dir))) { | 161 | while ((entry = readdir_uncached(dir))) { |
162 | if ( !strcasecmp(name, entry->d_name) ) { | 162 | if ( !strcasecmp(name, entry->d_name) ) { |
163 | fat_open(IF_MV2(dir->fatdir.file.volume,) | 163 | fat_open(IF_MV2(dir->fatdir.file.volume,) |
164 | entry->startcluster, | 164 | entry->startcluster, |
@@ -180,7 +180,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache) | |||
180 | DEBUGF("Couldn't create %s in %s\n",name,pathnamecopy); | 180 | DEBUGF("Couldn't create %s in %s\n",name,pathnamecopy); |
181 | errno = EIO; | 181 | errno = EIO; |
182 | file->busy = false; | 182 | file->busy = false; |
183 | closedir(dir); | 183 | closedir_uncached(dir); |
184 | return rc * 10 - 6; | 184 | return rc * 10 - 6; |
185 | } | 185 | } |
186 | #ifdef HAVE_DIRCACHE | 186 | #ifdef HAVE_DIRCACHE |
@@ -193,18 +193,18 @@ static int open_internal(const char* pathname, int flags, bool use_cache) | |||
193 | DEBUGF("Couldn't find %s in %s\n",name,pathnamecopy); | 193 | DEBUGF("Couldn't find %s in %s\n",name,pathnamecopy); |
194 | errno = ENOENT; | 194 | errno = ENOENT; |
195 | file->busy = false; | 195 | file->busy = false; |
196 | closedir(dir); | 196 | closedir_uncached(dir); |
197 | return -7; | 197 | return -7; |
198 | } | 198 | } |
199 | } else { | 199 | } else { |
200 | if(file->write && (file->attr & FAT_ATTR_DIRECTORY)) { | 200 | if(file->write && (file->attr & FAT_ATTR_DIRECTORY)) { |
201 | errno = EISDIR; | 201 | errno = EISDIR; |
202 | file->busy = false; | 202 | file->busy = false; |
203 | closedir(dir); | 203 | closedir_uncached(dir); |
204 | return -8; | 204 | return -8; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | closedir(dir); | 207 | closedir_uncached(dir); |
208 | 208 | ||
209 | file->cacheoffset = -1; | 209 | file->cacheoffset = -1; |
210 | file->fileoffset = 0; | 210 | file->fileoffset = 0; |
@@ -327,7 +327,7 @@ int remove(const char* name) | |||
327 | int rename(const char* path, const char* newpath) | 327 | int rename(const char* path, const char* newpath) |
328 | { | 328 | { |
329 | int rc, fd; | 329 | int rc, fd; |
330 | DIR* dir; | 330 | DIR_UNCACHED* dir; |
331 | char* nameptr; | 331 | char* nameptr; |
332 | char* dirptr; | 332 | char* dirptr; |
333 | struct filedesc* file; | 333 | struct filedesc* file; |
@@ -371,7 +371,7 @@ int rename(const char* path, const char* newpath) | |||
371 | dirptr = "/"; | 371 | dirptr = "/"; |
372 | } | 372 | } |
373 | 373 | ||
374 | dir = opendir(dirptr); | 374 | dir = opendir_uncached(dirptr); |
375 | if(!dir) | 375 | if(!dir) |
376 | return - 5; | 376 | return - 5; |
377 | 377 | ||
@@ -401,7 +401,7 @@ int rename(const char* path, const char* newpath) | |||
401 | return rc * 10 - 8; | 401 | return rc * 10 - 8; |
402 | } | 402 | } |
403 | 403 | ||
404 | rc = closedir(dir); | 404 | rc = closedir_uncached(dir); |
405 | if (rc<0) { | 405 | if (rc<0) { |
406 | errno = EIO; | 406 | errno = EIO; |
407 | return rc * 10 - 9; | 407 | return rc * 10 - 9; |
diff --git a/firmware/include/dir.h b/firmware/include/dir.h index 020b24a502..8778d0be02 100644 --- a/firmware/include/dir.h +++ b/firmware/include/dir.h | |||
@@ -7,7 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2002 by Björn Stenberg | 10 | * Copyright (C) 2007 by Kévin Ferrare |
11 | * | 11 | * |
12 | * All files in this archive are subject to the GNU General Public License. | 12 | * All files in this archive are subject to the GNU General Public License. |
13 | * See the file COPYING in the source tree root for full license agreement. | 13 | * See the file COPYING in the source tree root for full license agreement. |
@@ -16,76 +16,30 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | |||
19 | #ifndef _DIR_H_ | 20 | #ifndef _DIR_H_ |
20 | #define _DIR_H_ | 21 | #define _DIR_H_ |
21 | 22 | ||
22 | #include <stdbool.h> | 23 | #ifdef HAVE_DIRCACHE |
23 | #include "file.h" | 24 | # include "dircache.h" |
24 | 25 | # define DIR DIR_CACHED | |
25 | #define ATTR_READ_ONLY 0x01 | 26 | # define dirent dircache_entry |
26 | #define ATTR_HIDDEN 0x02 | 27 | # define opendir opendir_cached |
27 | #define ATTR_SYSTEM 0x04 | 28 | # define closedir closedir_cached |
28 | #define ATTR_VOLUME_ID 0x08 | 29 | # define readdir readdir_cached |
29 | #define ATTR_DIRECTORY 0x10 | 30 | # define closedir closedir_cached |
30 | #define ATTR_ARCHIVE 0x20 | 31 | # define mkdir mkdir_cached |
31 | #define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */ | 32 | # define rmdir rmdir_cached |
32 | |||
33 | #ifdef SIMULATOR | ||
34 | #define dirent sim_dirent | ||
35 | #define DIR SIM_DIR | ||
36 | #define opendir(x) sim_opendir(x) | ||
37 | #define readdir(x) sim_readdir(x) | ||
38 | #define closedir(x) sim_closedir(x) | ||
39 | #define mkdir(x) sim_mkdir(x) | ||
40 | #define rmdir(x) sim_rmdir(x) | ||
41 | #endif | ||
42 | |||
43 | #ifndef DIRENT_DEFINED | ||
44 | |||
45 | struct dirent { | ||
46 | unsigned char d_name[MAX_PATH]; | ||
47 | int attribute; | ||
48 | long size; | ||
49 | long startcluster; | ||
50 | unsigned short wrtdate; /* Last write date */ | ||
51 | unsigned short wrttime; /* Last write time */ | ||
52 | }; | ||
53 | #endif | ||
54 | |||
55 | #include "fat.h" | ||
56 | |||
57 | typedef struct { | ||
58 | #ifndef SIMULATOR | ||
59 | bool busy; | ||
60 | long startcluster; | ||
61 | struct fat_dir fatdir; | ||
62 | struct fat_dir parent_dir; | ||
63 | struct dirent theent; | ||
64 | #ifdef HAVE_MULTIVOLUME | ||
65 | int volumecounter; /* running counter for faked volume entries */ | ||
66 | #endif | ||
67 | #else | 33 | #else |
68 | /* simulator: */ | 34 | #include "dir_uncached.h" |
69 | void *dir; /* actually a DIR* dir */ | 35 | # define DIR DIR_UNCACHED |
70 | char *name; | 36 | # define dirent dirent_uncached |
71 | #endif | 37 | # define opendir opendir_uncached |
72 | } DIR; | 38 | # define closedir closedir_uncached |
73 | 39 | # define readdir readdir_uncached | |
74 | #ifdef HAVE_HOTSWAP | 40 | # define closedir closedir_uncached |
75 | char *get_volume_name(int volume); | 41 | # define mkdir mkdir_uncached |
42 | # define rmdir rmdir_uncached | ||
76 | #endif | 43 | #endif |
77 | 44 | ||
78 | #ifndef DIRFUNCTIONS_DEFINED | ||
79 | |||
80 | extern DIR* opendir(const char* name); | ||
81 | extern int closedir(DIR* dir); | ||
82 | extern int mkdir(const char* name); | ||
83 | extern int rmdir(const char* name); | ||
84 | |||
85 | extern struct dirent* readdir(DIR* dir); | ||
86 | |||
87 | extern int release_dirs(int volume); | ||
88 | |||
89 | #endif /* DIRFUNCTIONS_DEFINED */ | ||
90 | |||
91 | #endif | 45 | #endif |
diff --git a/firmware/include/dir_uncached.h b/firmware/include/dir_uncached.h new file mode 100644 index 0000000000..575c3b67e4 --- /dev/null +++ b/firmware/include/dir_uncached.h | |||
@@ -0,0 +1,91 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: dir.h 13741 2007-06-30 02:08:27Z jethead71 $ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Björn Stenberg | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef _DIR_UNCACHED_H_ | ||
20 | #define _DIR_UNCACHED_H_ | ||
21 | |||
22 | #include <stdbool.h> | ||
23 | #include "file.h" | ||
24 | |||
25 | #define ATTR_READ_ONLY 0x01 | ||
26 | #define ATTR_HIDDEN 0x02 | ||
27 | #define ATTR_SYSTEM 0x04 | ||
28 | #define ATTR_VOLUME_ID 0x08 | ||
29 | #define ATTR_DIRECTORY 0x10 | ||
30 | #define ATTR_ARCHIVE 0x20 | ||
31 | #define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */ | ||
32 | |||
33 | #ifdef SIMULATOR | ||
34 | #define dirent_uncached sim_dirent | ||
35 | #define DIR_UNCACHED SIM_DIR | ||
36 | #define opendir_uncached sim_opendir | ||
37 | #define readdir_uncached sim_readdir | ||
38 | #define closedir_uncached sim_closedir | ||
39 | #define mkdir_uncached sim_mkdir | ||
40 | #define rmdir_uncached sim_rmdir | ||
41 | #endif | ||
42 | |||
43 | #ifndef DIRENT_DEFINED | ||
44 | |||
45 | struct dirent_uncached { | ||
46 | unsigned char d_name[MAX_PATH]; | ||
47 | int attribute; | ||
48 | long size; | ||
49 | long startcluster; | ||
50 | unsigned short wrtdate; /* Last write date */ | ||
51 | unsigned short wrttime; /* Last write time */ | ||
52 | }; | ||
53 | #endif | ||
54 | |||
55 | #include "fat.h" | ||
56 | |||
57 | typedef struct { | ||
58 | #ifndef SIMULATOR | ||
59 | bool busy; | ||
60 | long startcluster; | ||
61 | struct fat_dir fatdir; | ||
62 | struct fat_dir parent_dir; | ||
63 | struct dirent_uncached theent; | ||
64 | #ifdef HAVE_MULTIVOLUME | ||
65 | int volumecounter; /* running counter for faked volume entries */ | ||
66 | #endif | ||
67 | #else | ||
68 | /* simulator: */ | ||
69 | void *dir; /* actually a DIR* dir */ | ||
70 | char *name; | ||
71 | #endif | ||
72 | } DIR_UNCACHED; | ||
73 | |||
74 | #ifdef HAVE_HOTSWAP | ||
75 | char *get_volume_name(int volume); | ||
76 | #endif | ||
77 | |||
78 | #ifndef DIRFUNCTIONS_DEFINED | ||
79 | |||
80 | extern DIR_UNCACHED* opendir_uncached(const char* name); | ||
81 | extern int closedir_uncached(DIR_UNCACHED* dir); | ||
82 | extern int mkdir_uncached(const char* name); | ||
83 | extern int rmdir_uncached(const char* name); | ||
84 | |||
85 | extern struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir); | ||
86 | |||
87 | extern int release_dirs(int volume); | ||
88 | |||
89 | #endif /* DIRFUNCTIONS_DEFINED */ | ||
90 | |||
91 | #endif | ||
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h index 1483843a73..6b47f3f1bb 100644 --- a/firmware/include/dircache.h +++ b/firmware/include/dircache.h | |||
@@ -19,7 +19,7 @@ | |||
19 | #ifndef _DIRCACHE_H | 19 | #ifndef _DIRCACHE_H |
20 | #define _DIRCACHE_H | 20 | #define _DIRCACHE_H |
21 | 21 | ||
22 | #include "dir.h" | 22 | #include "dir_uncached.h" |
23 | 23 | ||
24 | #ifdef HAVE_DIRCACHE | 24 | #ifdef HAVE_DIRCACHE |
25 | 25 | ||
@@ -34,8 +34,8 @@ struct travel_data { | |||
34 | struct dircache_entry *ce; | 34 | struct dircache_entry *ce; |
35 | struct dircache_entry *down_entry; | 35 | struct dircache_entry *down_entry; |
36 | #ifdef SIMULATOR | 36 | #ifdef SIMULATOR |
37 | DIR *dir, *newdir; | 37 | DIR_UNCACHED *dir, *newdir; |
38 | struct dirent *entry; | 38 | struct dirent_uncached *entry; |
39 | #else | 39 | #else |
40 | struct fat_dir *dir; | 40 | struct fat_dir *dir; |
41 | struct fat_dir newdir; | 41 | struct fat_dir newdir; |
@@ -77,8 +77,8 @@ typedef struct { | |||
77 | struct dircache_entry *entry; | 77 | struct dircache_entry *entry; |
78 | struct dircache_entry *internal_entry; | 78 | struct dircache_entry *internal_entry; |
79 | struct dircache_entry secondary_entry; | 79 | struct dircache_entry secondary_entry; |
80 | DIR *regulardir; | 80 | DIR_UNCACHED *regulardir; |
81 | } DIRCACHED; | 81 | } DIR_CACHED; |
82 | 82 | ||
83 | void dircache_init(void); | 83 | void dircache_init(void); |
84 | int dircache_load(void); | 84 | int dircache_load(void); |
@@ -103,17 +103,11 @@ void dircache_remove(const char *name); | |||
103 | void dircache_rename(const char *oldpath, const char *newpath); | 103 | void dircache_rename(const char *oldpath, const char *newpath); |
104 | void dircache_add_file(const char *path, long startcluster); | 104 | void dircache_add_file(const char *path, long startcluster); |
105 | 105 | ||
106 | DIRCACHED* opendir_cached(const char* name); | 106 | DIR_CACHED* opendir_cached(const char* name); |
107 | struct dircache_entry* readdir_cached(DIRCACHED* dir); | 107 | struct dircache_entry* readdir_cached(DIR_CACHED* dir); |
108 | int closedir_cached(DIRCACHED *dir); | 108 | int closedir_cached(DIR_CACHED *dir); |
109 | 109 | int mkdir_cached(const char *name); | |
110 | #else /* HAVE_DIRCACHE */ | 110 | int rmdir_cached(const char* name); |
111 | # define DIRCACHED DIR | ||
112 | # define dircache_entry dirent | ||
113 | # define opendir_cached opendir | ||
114 | # define closedir_cached closedir | ||
115 | # define readdir_cached readdir | ||
116 | # define closedir_cached closedir | ||
117 | #endif /* !HAVE_DIRCACHE */ | 111 | #endif /* !HAVE_DIRCACHE */ |
118 | 112 | ||
119 | #endif | 113 | #endif |