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