diff options
Diffstat (limited to 'firmware/include/dircache_redirect.h')
-rw-r--r-- | firmware/include/dircache_redirect.h | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h new file mode 100644 index 0000000000..15fb4bc38d --- /dev/null +++ b/firmware/include/dircache_redirect.h | |||
@@ -0,0 +1,198 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2014 by Michael Sevakis | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _DIRCACHE_REDIRECT_H_ | ||
22 | |||
23 | #include "dir.h" | ||
24 | |||
25 | /*** | ||
26 | ** Internal redirects that depend upon whether or not dircache is made | ||
27 | **/ | ||
28 | |||
29 | /** File binding **/ | ||
30 | |||
31 | static inline void get_rootinfo_internal(struct file_base_info *infop) | ||
32 | { | ||
33 | #ifdef HAVE_DIRCACHE | ||
34 | dircache_get_rootinfo(infop); | ||
35 | #else | ||
36 | (void)infop; | ||
37 | #endif | ||
38 | } | ||
39 | |||
40 | static inline void fileobj_bind_file(struct file_base_binding *bindp) | ||
41 | { | ||
42 | #ifdef HAVE_DIRCACHE | ||
43 | dircache_bind_file(bindp); | ||
44 | #else | ||
45 | file_binding_insert_last(bindp); | ||
46 | #endif | ||
47 | } | ||
48 | |||
49 | static inline void fileobj_unbind_file(struct file_base_binding *bindp) | ||
50 | { | ||
51 | #ifdef HAVE_DIRCACHE | ||
52 | dircache_unbind_file(bindp); | ||
53 | #else | ||
54 | file_binding_remove(bindp); | ||
55 | #endif | ||
56 | } | ||
57 | |||
58 | |||
59 | /** File event handlers **/ | ||
60 | |||
61 | static inline void fileop_onopen_internal(struct filestr_base *stream, | ||
62 | struct file_base_info *srcinfop, | ||
63 | unsigned int callflags) | ||
64 | { | ||
65 | fileobj_fileop_open(stream, srcinfop, callflags); | ||
66 | } | ||
67 | |||
68 | static inline void fileop_onclose_internal(struct filestr_base *stream) | ||
69 | { | ||
70 | fileobj_fileop_close(stream); | ||
71 | } | ||
72 | |||
73 | static inline void fileop_oncreate_internal(struct filestr_base *stream, | ||
74 | struct file_base_info *srcinfop, | ||
75 | unsigned int callflags, | ||
76 | struct file_base_info *dirinfop, | ||
77 | const char *basename) | ||
78 | { | ||
79 | #ifdef HAVE_DIRCACHE | ||
80 | dircache_dcfile_init(&srcinfop->dcfile); | ||
81 | #endif | ||
82 | fileobj_fileop_create(stream, srcinfop, callflags); | ||
83 | #ifdef HAVE_DIRCACHE | ||
84 | struct dirinfo_native din; | ||
85 | fill_dirinfo_native(&din); | ||
86 | dircache_fileop_create(dirinfop, stream->bindp, basename, &din); | ||
87 | #endif | ||
88 | (void)dirinfop; (void)basename; | ||
89 | } | ||
90 | |||
91 | static inline void fileop_onremove_internal(struct filestr_base *stream, | ||
92 | struct file_base_info *oldinfop) | ||
93 | { | ||
94 | fileobj_fileop_remove(stream, oldinfop); | ||
95 | #ifdef HAVE_DIRCACHE | ||
96 | dircache_fileop_remove(stream->bindp); | ||
97 | #endif | ||
98 | } | ||
99 | |||
100 | static inline void fileop_onrename_internal(struct filestr_base *stream, | ||
101 | struct file_base_info *oldinfop, | ||
102 | struct file_base_info *dirinfop, | ||
103 | const char *basename) | ||
104 | { | ||
105 | fileobj_fileop_rename(stream, oldinfop); | ||
106 | #ifdef HAVE_DIRCACHE | ||
107 | dircache_fileop_rename(dirinfop, stream->bindp, basename); | ||
108 | #endif | ||
109 | (void)dirinfop; (void)basename; | ||
110 | } | ||
111 | |||
112 | static inline void fileop_onsync_internal(struct filestr_base *stream) | ||
113 | { | ||
114 | fileobj_fileop_sync(stream); | ||
115 | #ifdef HAVE_DIRCACHE | ||
116 | struct dirinfo_native din; | ||
117 | fill_dirinfo_native(&din); | ||
118 | dircache_fileop_sync(stream->bindp, &din); | ||
119 | #endif | ||
120 | } | ||
121 | |||
122 | static inline void fileop_ontruncate_internal(struct filestr_base *stream) | ||
123 | { | ||
124 | fileobj_fileop_truncate(stream); | ||
125 | } | ||
126 | |||
127 | static inline void volume_onmount_internal(IF_MV_NONVOID(int volume)) | ||
128 | { | ||
129 | #ifdef HAVE_DIRCACHE | ||
130 | dircache_mount(); | ||
131 | #endif | ||
132 | IF_MV( (void)volume; ) | ||
133 | } | ||
134 | |||
135 | static inline void volume_onunmount_internal(IF_MV_NONVOID(int volume)) | ||
136 | { | ||
137 | fileobj_mgr_unmount(IF_MV(volume)); | ||
138 | #ifdef HAVE_DIRCACHE | ||
139 | dircache_unmount(IF_MV(volume)); | ||
140 | #endif | ||
141 | } | ||
142 | |||
143 | |||
144 | /** Directory reading **/ | ||
145 | |||
146 | static inline int readdir_dirent(struct filestr_base *stream, | ||
147 | struct dirscan_info *scanp, | ||
148 | struct dirent *entry) | ||
149 | { | ||
150 | #ifdef HAVE_DIRCACHE | ||
151 | return dircache_readdir_dirent(stream, scanp, entry); | ||
152 | #else | ||
153 | return uncached_readdir_dirent(stream, scanp, entry); | ||
154 | #endif | ||
155 | } | ||
156 | |||
157 | static inline void rewinddir_dirent(struct dirscan_info *scanp) | ||
158 | { | ||
159 | #ifdef HAVE_DIRCACHE | ||
160 | dircache_rewinddir_dirent(scanp); | ||
161 | #else | ||
162 | uncached_rewinddir_dirent(scanp); | ||
163 | #endif | ||
164 | } | ||
165 | |||
166 | static inline int readdir_internal(struct filestr_base *stream, | ||
167 | struct file_base_info *infop, | ||
168 | struct fat_direntry *fatent) | ||
169 | { | ||
170 | #ifdef HAVE_DIRCACHE | ||
171 | return dircache_readdir_internal(stream, infop, fatent); | ||
172 | #else | ||
173 | return uncached_readdir_internal(stream, infop, fatent); | ||
174 | #endif | ||
175 | } | ||
176 | |||
177 | static inline void rewinddir_internal(struct file_base_info *infop) | ||
178 | { | ||
179 | #ifdef HAVE_DIRCACHE | ||
180 | dircache_rewinddir_internal(infop); | ||
181 | #else | ||
182 | uncached_rewinddir_internal(infop); | ||
183 | #endif | ||
184 | } | ||
185 | |||
186 | |||
187 | /** Misc. stuff **/ | ||
188 | |||
189 | static inline struct fat_direntry *get_dir_fatent_dircache(void) | ||
190 | { | ||
191 | #ifdef HAVE_DIRCACHE | ||
192 | return get_dir_fatent(); | ||
193 | #else | ||
194 | return NULL; | ||
195 | #endif | ||
196 | } | ||
197 | |||
198 | #endif /* _DIRCACHE_REDIRECT_H_ */ | ||