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 ****************************************************************************/
25 #include "dir_uncached.h"
26 #include <string.h> /* size_t */
30 #define DIRCACHE_RESERVE (1024*64)
31 #define DIRCACHE_LIMIT (1024*1024*6)
33 #define DIRCACHE_APPFLAG_TAGCACHE 0x0001
34 #define DIRCACHE_APPFLAG_PLAYLIST 0x0002
36 /* Internal structures. */
38 struct dircache_entry
*first
;
39 struct dircache_entry
*ce
;
40 struct dircache_entry
*down_entry
;
41 #if (CONFIG_PLATFORM & PLATFORM_HOSTED)
42 DIR_UNCACHED
*dir
, *newdir
;
43 struct dirent_uncached
*entry
;
46 struct fat_dir newdir
;
47 struct fat_direntry entry
;
52 struct dirent_cached
{
60 struct dirent_cached theent
; /* .attribute is set to -1 on init(opendir) */
61 int internal_entry
; /* the current entry in the directory */
62 DIR_UNCACHED
*regulardir
;
65 void dircache_init(void) INIT_ATTR
;
66 int dircache_load(void);
67 int dircache_save(void);
68 int dircache_build(int last_size
);
69 void* dircache_steal_buffer(size_t *size
);
70 bool dircache_is_enabled(void);
71 bool dircache_is_initializing(void);
72 void dircache_set_appflag(long mask
);
73 bool dircache_get_appflag(long mask
);
74 int dircache_get_entry_count(void);
75 int dircache_get_cache_size(void);
76 int dircache_get_reserve_used(void);
77 int dircache_get_build_ticks(void);
78 void dircache_disable(void);
79 int dircache_get_entry_id(const char *filename
);
80 size_t dircache_copy_path(int index
, char *buf
, size_t size
);
82 /* the next two are internal for file.c */
83 long _dircache_get_entry_startcluster(int id
);
84 struct dirinfo
* _dircache_get_entry_dirinfo(int id
);
86 void dircache_bind(int fd
, const char *path
);
87 void dircache_update_filesize(int fd
, long newsize
, long startcluster
);
88 void dircache_update_filetime(int fd
);
89 void dircache_mkdir(const char *path
);
90 void dircache_rmdir(const char *path
);
91 void dircache_remove(const char *name
);
92 void dircache_rename(const char *oldpath
, const char *newpath
);
93 void dircache_add_file(const char *path
, long startcluster
);
95 DIR_CACHED
* opendir_cached(const char* name
);
96 struct dirent_cached
* readdir_cached(DIR_CACHED
* dir
);
97 int closedir_cached(DIR_CACHED
*dir
);
98 int mkdir_cached(const char *name
);
99 int rmdir_cached(const char* name
);
100 #endif /* !HAVE_DIRCACHE */