lcd dimensions from configure
[kugel-rb.git] / firmware / include / dircache.h
blob650b92632d9497440f54b208c94168a00b814478
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #ifndef _DIRCACHE_H
22 #define _DIRCACHE_H
24 #include "dir_uncached.h"
26 #ifdef HAVE_DIRCACHE
28 #define DIRCACHE_RESERVE (1024*64)
29 #define DIRCACHE_LIMIT (1024*1024*6)
31 #define DIRCACHE_APPFLAG_TAGCACHE 0x0001
33 /* Internal structures. */
34 struct travel_data {
35 struct dircache_entry *first;
36 struct dircache_entry *ce;
37 struct dircache_entry *down_entry;
38 #if (CONFIG_PLATFORM & PLATFORM_HOSTED)
39 DIR_UNCACHED *dir, *newdir;
40 struct dirent_uncached *entry;
41 #else
42 struct fat_dir *dir;
43 struct fat_dir newdir;
44 struct fat_direntry entry;
45 #endif
46 int pathpos;
49 #define DIRCACHE_MAGIC 0x00d0c0a0
50 struct dircache_maindata {
51 long magic;
52 long size;
53 long entry_count;
54 long appflags;
55 struct dircache_entry *root_entry;
58 #define MAX_PENDING_BINDINGS 2
59 struct fdbind_queue {
60 char path[MAX_PATH];
61 int fd;
64 /* Exported structures. */
65 struct dircache_entry {
66 struct dircache_entry *next;
67 struct dircache_entry *up;
68 struct dircache_entry *down;
69 int attribute;
70 long size;
71 long startcluster;
72 unsigned short wrtdate;
73 unsigned short wrttime;
74 unsigned long name_len;
75 char *d_name;
78 struct dirent_cached {
79 char *d_name;
80 int attribute;
81 long size;
82 long startcluster;
83 unsigned short wrtdate; /* Last write date */
84 unsigned short wrttime; /* Last write time */
87 typedef struct {
88 bool busy;
89 struct dirent_cached theent; /* .attribute is set to -1 on init(opendir) */
90 struct dircache_entry *internal_entry; /* the current entry in the directory */
91 DIR_UNCACHED *regulardir;
92 } DIR_CACHED;
94 void dircache_init(void) INIT_ATTR;
95 int dircache_load(void);
96 int dircache_save(void);
97 int dircache_build(int last_size);
98 void* dircache_steal_buffer(long *size);
99 bool dircache_is_enabled(void);
100 bool dircache_is_initializing(void);
101 void dircache_set_appflag(long mask);
102 bool dircache_get_appflag(long mask);
103 int dircache_get_entry_count(void);
104 int dircache_get_cache_size(void);
105 int dircache_get_reserve_used(void);
106 int dircache_get_build_ticks(void);
107 void dircache_disable(void);
108 const struct dircache_entry *dircache_get_entry_ptr(const char *filename);
109 void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size);
111 void dircache_bind(int fd, const char *path);
112 void dircache_update_filesize(int fd, long newsize, long startcluster);
113 void dircache_update_filetime(int fd);
114 void dircache_mkdir(const char *path);
115 void dircache_rmdir(const char *path);
116 void dircache_remove(const char *name);
117 void dircache_rename(const char *oldpath, const char *newpath);
118 void dircache_add_file(const char *path, long startcluster);
120 DIR_CACHED* opendir_cached(const char* name);
121 struct dirent_cached* readdir_cached(DIR_CACHED* dir);
122 int closedir_cached(DIR_CACHED *dir);
123 int mkdir_cached(const char *name);
124 int rmdir_cached(const char* name);
125 #endif /* !HAVE_DIRCACHE */
127 #endif