blob: 93bc413dc9a836b700de4b8ad556dd2bc61731d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Miika Pekkarinen
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _DIRCACHE_H
#define _DIRCACHE_H
#include "dir.h"
#ifdef HAVE_DIRCACHE
#define DIRCACHE_RESERVE (1024*64)
#define DIRCACHE_LIMIT (1024*1024*6)
#define DIRCACHE_FILE ROCKBOX_DIR "/dircache.dat"
/* Internal structures. */
struct travel_data {
struct dircache_entry *first;
struct dircache_entry *ce;
struct dircache_entry *down_entry;
struct fat_dir *dir;
struct fat_dir newdir;
struct fat_direntry entry;
int pathpos;
};
#define DIRCACHE_MAGIC 0x00d0c0a0
struct dircache_maindata {
long magic;
long size;
long entry_count;
struct dircache_entry *root_entry;
};
/* Exported structures. */
struct dircache_entry {
struct dircache_entry *next;
struct dircache_entry *up;
struct dircache_entry *down;
int attribute;
long size;
long startcluster;
unsigned short wrtdate;
unsigned short wrttime;
unsigned char name_len;
char *d_name;
};
typedef struct {
bool busy;
struct dircache_entry *entry;
struct dircache_entry *internal_entry;
struct dircache_entry secondary_entry;
DIR *regulardir;
} DIRCACHED;
void dircache_init(void);
int dircache_load(const char *path);
int dircache_save(const char *path);
int dircache_build(int last_size);
bool dircache_is_enabled(void);
int dircache_get_entry_count(void);
int dircache_get_cache_size(void);
int dircache_get_reserve_used(void);
int dircache_get_build_ticks(void);
void dircache_disable(void);
const struct dircache_entry *dircache_get_entry_ptr(const char *filename);
void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size);
void dircache_bind(int fd, const char *path);
void dircache_update_filesize(int fd, long newsize);
void dircache_mkdir(const char *path);
void dircache_rmdir(const char *path);
void dircache_remove(const char *name);
void dircache_rename(const char *oldpath, const char *newpath);
void dircache_add_file(const char *path);
DIRCACHED* opendir_cached(const char* name);
struct dircache_entry* readdir_cached(DIRCACHED* dir);
int closedir_cached(DIRCACHED *dir);
#else /* HAVE_DIRCACHE */
# define DIRCACHED DIR
# define dircache_entry dirent
# define opendir_cached opendir
# define closedir_cached closedir
# define readdir_cached readdir
# define closedir_cached closedir
#endif /* !HAVE_DIRCACHE */
#endif
|