2005-10-07 17:38:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* 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)
|
2006-02-28 11:41:35 +00:00
|
|
|
#define DIRCACHE_LIMIT (1024*1024*6)
|
2005-10-07 17:38:05 +00:00
|
|
|
#define DIRCACHE_FILE ROCKBOX_DIR "/dircache.dat"
|
|
|
|
|
|
|
|
/* Internal structures. */
|
|
|
|
struct travel_data {
|
2006-02-28 11:41:35 +00:00
|
|
|
struct dircache_entry *first;
|
2005-10-07 17:38:05 +00:00
|
|
|
struct dircache_entry *ce;
|
|
|
|
struct dircache_entry *down_entry;
|
2006-03-30 18:53:44 +00:00
|
|
|
#ifdef SIMULATOR
|
|
|
|
DIR *dir, *newdir;
|
|
|
|
struct dirent *entry;
|
|
|
|
#else
|
2005-10-07 17:38:05 +00:00
|
|
|
struct fat_dir *dir;
|
|
|
|
struct fat_dir newdir;
|
|
|
|
struct fat_direntry entry;
|
2006-03-30 18:53:44 +00:00
|
|
|
#endif
|
2005-10-07 17:38:05 +00:00
|
|
|
int pathpos;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DIRCACHE_MAGIC 0x00d0c0a0
|
|
|
|
struct dircache_maindata {
|
|
|
|
long magic;
|
|
|
|
long size;
|
2006-01-31 10:08:53 +00:00
|
|
|
long entry_count;
|
2005-10-07 17:38:05 +00:00
|
|
|
struct dircache_entry *root_entry;
|
|
|
|
};
|
|
|
|
|
2006-03-29 09:38:45 +00:00
|
|
|
#define MAX_PENDING_BINDINGS 2
|
|
|
|
struct fdbind_queue {
|
|
|
|
char path[MAX_PATH];
|
|
|
|
int fd;
|
|
|
|
};
|
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
/* Exported structures. */
|
|
|
|
struct dircache_entry {
|
|
|
|
struct dircache_entry *next;
|
2005-11-17 19:31:29 +00:00
|
|
|
struct dircache_entry *up;
|
2005-10-07 17:38:05 +00:00
|
|
|
struct dircache_entry *down;
|
|
|
|
int attribute;
|
|
|
|
long size;
|
|
|
|
long startcluster;
|
|
|
|
unsigned short wrtdate;
|
|
|
|
unsigned short wrttime;
|
2006-11-10 08:03:33 +00:00
|
|
|
unsigned long name_len;
|
2005-10-07 17:38:05 +00:00
|
|
|
char *d_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
bool busy;
|
|
|
|
struct dircache_entry *entry;
|
2006-01-31 10:08:53 +00:00
|
|
|
struct dircache_entry *internal_entry;
|
2005-10-07 17:38:05 +00:00
|
|
|
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);
|
2006-04-16 17:32:54 +00:00
|
|
|
void* dircache_steal_buffer(long *size);
|
2005-10-07 17:38:05 +00:00
|
|
|
bool dircache_is_enabled(void);
|
2006-07-10 16:22:03 +00:00
|
|
|
bool dircache_is_initializing(void);
|
2006-01-31 10:08:53 +00:00
|
|
|
int dircache_get_entry_count(void);
|
2005-10-07 17:38:05 +00:00
|
|
|
int dircache_get_cache_size(void);
|
2005-11-26 20:22:19 +00:00
|
|
|
int dircache_get_reserve_used(void);
|
2005-11-26 23:47:06 +00:00
|
|
|
int dircache_get_build_ticks(void);
|
2005-10-07 17:38:05 +00:00
|
|
|
void dircache_disable(void);
|
2005-11-17 19:31:29 +00:00
|
|
|
const struct dircache_entry *dircache_get_entry_ptr(const char *filename);
|
|
|
|
void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size);
|
2005-10-07 17:38:05 +00:00
|
|
|
|
|
|
|
void dircache_bind(int fd, const char *path);
|
2006-03-28 11:51:12 +00:00
|
|
|
void dircache_update_filesize(int fd, long newsize, long startcluster);
|
2005-10-07 17:38:05 +00:00
|
|
|
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);
|
2006-03-28 11:51:12 +00:00
|
|
|
void dircache_add_file(const char *path, long startcluster);
|
2005-10-07 17:38:05 +00:00
|
|
|
|
|
|
|
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
|