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