Prepare new maemo release
[maemo-rb.git] / firmware / include / dircache.h
blob019ccf49b753ec223887c95ae8dbd3c74ad5af2e
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 "config.h"
25 #include "dir_uncached.h"
26 #include <string.h> /* size_t */
28 #ifdef HAVE_DIRCACHE
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. */
37 struct travel_data {
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;
44 #else
45 struct fat_dir *dir;
46 struct fat_dir newdir;
47 struct fat_direntry entry;
48 #endif
49 int pathpos;
52 struct dirent_cached {
53 struct dirinfo info;
54 char *d_name;
55 long startcluster;
58 typedef struct {
59 bool busy;
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;
63 } DIR_CACHED;
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 void dircache_suspend(void);
80 bool dircache_resume(void);
81 int dircache_get_entry_id(const char *filename);
82 size_t dircache_copy_path(int index, char *buf, size_t size);
84 /* the next two are internal for file.c */
85 long _dircache_get_entry_startcluster(int id);
86 struct dirinfo* _dircache_get_entry_dirinfo(int id);
88 void dircache_bind(int fd, const char *path);
89 void dircache_update_filesize(int fd, long newsize, long startcluster);
90 void dircache_update_filetime(int fd);
91 void dircache_mkdir(const char *path);
92 void dircache_rmdir(const char *path);
93 void dircache_remove(const char *name);
94 void dircache_rename(const char *oldpath, const char *newpath);
95 void dircache_add_file(const char *path, long startcluster);
97 DIR_CACHED* opendir_cached(const char* name);
98 struct dirent_cached* readdir_cached(DIR_CACHED* dir);
99 int closedir_cached(DIR_CACHED *dir);
100 int mkdir_cached(const char *name);
101 int rmdir_cached(const char* name);
102 #endif /* !HAVE_DIRCACHE */
104 #endif