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 #define DIRCACHE_FILE ROCKBOX_DIR"/dircache.dat"
32 #define DIRCACHE_APPFLAG_TAGCACHE 0x0001
34 /* Internal structures. */
36 struct dircache_entry
*first
;
37 struct dircache_entry
*ce
;
38 struct dircache_entry
*down_entry
;
40 DIR_UNCACHED
*dir
, *newdir
;
41 struct dirent_uncached
*entry
;
44 struct fat_dir newdir
;
45 struct fat_direntry entry
;
50 #define DIRCACHE_MAGIC 0x00d0c0a0
51 struct dircache_maindata
{
56 struct dircache_entry
*root_entry
;
59 #define MAX_PENDING_BINDINGS 2
65 /* Exported structures. */
66 struct dircache_entry
{
67 struct dircache_entry
*next
;
68 struct dircache_entry
*up
;
69 struct dircache_entry
*down
;
73 unsigned short wrtdate
;
74 unsigned short wrttime
;
75 unsigned long name_len
;
81 struct dircache_entry
*entry
;
82 struct dircache_entry
*internal_entry
;
83 struct dircache_entry secondary_entry
;
84 DIR_UNCACHED
*regulardir
;
87 void dircache_init(void);
88 int dircache_load(void);
89 int dircache_save(void);
90 int dircache_build(int last_size
);
91 void* dircache_steal_buffer(long *size
);
92 bool dircache_is_enabled(void);
93 bool dircache_is_initializing(void);
94 void dircache_set_appflag(long mask
);
95 bool dircache_get_appflag(long mask
);
96 int dircache_get_entry_count(void);
97 int dircache_get_cache_size(void);
98 int dircache_get_reserve_used(void);
99 int dircache_get_build_ticks(void);
100 void dircache_disable(void);
101 const struct dircache_entry
*dircache_get_entry_ptr(const char *filename
);
102 void dircache_copy_path(const struct dircache_entry
*entry
, char *buf
, int size
);
104 void dircache_bind(int fd
, const char *path
);
105 void dircache_update_filesize(int fd
, long newsize
, long startcluster
);
106 void dircache_update_filetime(int fd
);
107 void dircache_mkdir(const char *path
);
108 void dircache_rmdir(const char *path
);
109 void dircache_remove(const char *name
);
110 void dircache_rename(const char *oldpath
, const char *newpath
);
111 void dircache_add_file(const char *path
, long startcluster
);
113 DIR_CACHED
* opendir_cached(const char* name
);
114 struct dircache_entry
* readdir_cached(DIR_CACHED
* dir
);
115 int closedir_cached(DIR_CACHED
*dir
);
116 int mkdir_cached(const char *name
);
117 int rmdir_cached(const char* name
);
118 #endif /* !HAVE_DIRCACHE */