2005-10-07 17:38:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Miika Pekkarinen
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-10-07 17:38:05 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef _DIRCACHE_H
|
|
|
|
#define _DIRCACHE_H
|
|
|
|
|
2007-07-20 17:06:55 +00:00
|
|
|
#include "dir_uncached.h"
|
2005-10-07 17:38:05 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_DIRCACHE
|
|
|
|
|
|
|
|
#define DIRCACHE_RESERVE (1024*64)
|
2006-02-28 11:41:35 +00:00
|
|
|
#define DIRCACHE_LIMIT (1024*1024*6)
|
2008-11-24 22:16:07 +00:00
|
|
|
#define DIRCACHE_FILE ROCKBOX_DIR"/dircache.dat"
|
2005-10-07 17:38:05 +00:00
|
|
|
|
2008-01-13 19:13:37 +00:00
|
|
|
#define DIRCACHE_APPFLAG_TAGCACHE 0x0001
|
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
/* 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
|
2007-07-20 17:06:55 +00:00
|
|
|
DIR_UNCACHED *dir, *newdir;
|
|
|
|
struct dirent_uncached *entry;
|
2006-03-30 18:53:44 +00:00
|
|
|
#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;
|
2008-01-13 19:13:37 +00:00
|
|
|
long appflags;
|
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;
|
2007-07-20 17:06:55 +00:00
|
|
|
DIR_UNCACHED *regulardir;
|
|
|
|
} DIR_CACHED;
|
2005-10-07 17:38:05 +00:00
|
|
|
|
|
|
|
void dircache_init(void);
|
2006-12-22 09:11:09 +00:00
|
|
|
int dircache_load(void);
|
|
|
|
int dircache_save(void);
|
2005-10-07 17:38:05 +00:00
|
|
|
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);
|
2008-01-13 19:13:37 +00:00
|
|
|
void dircache_set_appflag(long mask);
|
|
|
|
bool dircache_get_appflag(long mask);
|
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);
|
2007-09-02 13:24:51 +00:00
|
|
|
void dircache_update_filetime(int fd);
|
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
|
|
|
|
2007-07-20 17:06:55 +00:00
|
|
|
DIR_CACHED* opendir_cached(const char* name);
|
|
|
|
struct dircache_entry* readdir_cached(DIR_CACHED* dir);
|
|
|
|
int closedir_cached(DIR_CACHED *dir);
|
|
|
|
int mkdir_cached(const char *name);
|
|
|
|
int rmdir_cached(const char* name);
|
2005-10-07 17:38:05 +00:00
|
|
|
#endif /* !HAVE_DIRCACHE */
|
|
|
|
|
|
|
|
#endif
|