diff options
Diffstat (limited to 'firmware/include')
-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 |
3 files changed, 122 insertions, 83 deletions
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 |