1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Miika Pekkarinen
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
22 #include "dir_uncached.h"
26 #define DIRCACHE_RESERVE (1024*64)
27 #define DIRCACHE_LIMIT (1024*1024*6)
28 /* FIXME: We should use ROCKBOX_DIR here but it's defined in apps/ */
29 #define DIRCACHE_FILE "/.rockbox/dircache.dat"
31 #define DIRCACHE_APPFLAG_TAGCACHE 0x0001
33 /* Internal structures. */
35 struct dircache_entry
*first
;
36 struct dircache_entry
*ce
;
37 struct dircache_entry
*down_entry
;
39 DIR_UNCACHED
*dir
, *newdir
;
40 struct dirent_uncached
*entry
;
43 struct fat_dir newdir
;
44 struct fat_direntry entry
;
49 #define DIRCACHE_MAGIC 0x00d0c0a0
50 struct dircache_maindata
{
55 struct dircache_entry
*root_entry
;
58 #define MAX_PENDING_BINDINGS 2
64 /* Exported structures. */
65 struct dircache_entry
{
66 struct dircache_entry
*next
;
67 struct dircache_entry
*up
;
68 struct dircache_entry
*down
;
72 unsigned short wrtdate
;
73 unsigned short wrttime
;
74 unsigned long name_len
;
80 struct dircache_entry
*entry
;
81 struct dircache_entry
*internal_entry
;
82 struct dircache_entry secondary_entry
;
83 DIR_UNCACHED
*regulardir
;
86 void dircache_init(void);
87 int dircache_load(void);
88 int dircache_save(void);
89 int dircache_build(int last_size
);
90 void* dircache_steal_buffer(long *size
);
91 bool dircache_is_enabled(void);
92 bool dircache_is_initializing(void);
93 void dircache_set_appflag(long mask
);
94 bool dircache_get_appflag(long mask
);
95 int dircache_get_entry_count(void);
96 int dircache_get_cache_size(void);
97 int dircache_get_reserve_used(void);
98 int dircache_get_build_ticks(void);
99 void dircache_disable(void);
100 const struct dircache_entry
*dircache_get_entry_ptr(const char *filename
);
101 void dircache_copy_path(const struct dircache_entry
*entry
, char *buf
, int size
);
103 void dircache_bind(int fd
, const char *path
);
104 void dircache_update_filesize(int fd
, long newsize
, long startcluster
);
105 void dircache_update_filetime(int fd
);
106 void dircache_mkdir(const char *path
);
107 void dircache_rmdir(const char *path
);
108 void dircache_remove(const char *name
);
109 void dircache_rename(const char *oldpath
, const char *newpath
);
110 void dircache_add_file(const char *path
, long startcluster
);
112 DIR_CACHED
* opendir_cached(const char* name
);
113 struct dircache_entry
* readdir_cached(DIR_CACHED
* dir
);
114 int closedir_cached(DIR_CACHED
*dir
);
115 int mkdir_cached(const char *name
);
116 int rmdir_cached(const char* name
);
117 #endif /* !HAVE_DIRCACHE */