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 /* Internal structures. */
33 struct dircache_entry
*first
;
34 struct dircache_entry
*ce
;
35 struct dircache_entry
*down_entry
;
37 DIR_UNCACHED
*dir
, *newdir
;
38 struct dirent_uncached
*entry
;
41 struct fat_dir newdir
;
42 struct fat_direntry entry
;
47 #define DIRCACHE_MAGIC 0x00d0c0a0
48 struct dircache_maindata
{
52 struct dircache_entry
*root_entry
;
55 #define MAX_PENDING_BINDINGS 2
61 /* Exported structures. */
62 struct dircache_entry
{
63 struct dircache_entry
*next
;
64 struct dircache_entry
*up
;
65 struct dircache_entry
*down
;
69 unsigned short wrtdate
;
70 unsigned short wrttime
;
71 unsigned long name_len
;
77 struct dircache_entry
*entry
;
78 struct dircache_entry
*internal_entry
;
79 struct dircache_entry secondary_entry
;
80 DIR_UNCACHED
*regulardir
;
83 void dircache_init(void);
84 int dircache_load(void);
85 int dircache_save(void);
86 int dircache_build(int last_size
);
87 void* dircache_steal_buffer(long *size
);
88 bool dircache_is_enabled(void);
89 bool dircache_is_initializing(void);
90 int dircache_get_entry_count(void);
91 int dircache_get_cache_size(void);
92 int dircache_get_reserve_used(void);
93 int dircache_get_build_ticks(void);
94 void dircache_disable(void);
95 const struct dircache_entry
*dircache_get_entry_ptr(const char *filename
);
96 void dircache_copy_path(const struct dircache_entry
*entry
, char *buf
, int size
);
98 void dircache_bind(int fd
, const char *path
);
99 void dircache_update_filesize(int fd
, long newsize
, long startcluster
);
100 void dircache_update_filetime(int fd
);
101 void dircache_mkdir(const char *path
);
102 void dircache_rmdir(const char *path
);
103 void dircache_remove(const char *name
);
104 void dircache_rename(const char *oldpath
, const char *newpath
);
105 void dircache_add_file(const char *path
, long startcluster
);
107 DIR_CACHED
* opendir_cached(const char* name
);
108 struct dircache_entry
* readdir_cached(DIR_CACHED
* dir
);
109 int closedir_cached(DIR_CACHED
*dir
);
110 int mkdir_cached(const char *name
);
111 int rmdir_cached(const char* name
);
112 #endif /* !HAVE_DIRCACHE */