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
|
|
|
|
|
2010-09-01 21:45:58 +00:00
|
|
|
#include "config.h"
|
2007-07-20 17:06:55 +00:00
|
|
|
#include "dir_uncached.h"
|
2011-08-14 15:13:00 +00:00
|
|
|
#include <string.h> /* size_t */
|
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)
|
2005-10-07 17:38:05 +00:00
|
|
|
|
2008-01-13 19:13:37 +00:00
|
|
|
#define DIRCACHE_APPFLAG_TAGCACHE 0x0001
|
2011-06-21 17:42:31 +00:00
|
|
|
#define DIRCACHE_APPFLAG_PLAYLIST 0x0002
|
2008-01-13 19:13:37 +00:00
|
|
|
|
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;
|
2010-06-21 16:53:00 +00:00
|
|
|
#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
|
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;
|
|
|
|
};
|
|
|
|
|
2010-02-16 22:49:11 +00:00
|
|
|
struct dirent_cached {
|
2010-09-01 21:29:34 +00:00
|
|
|
struct dirinfo info;
|
2010-02-16 22:49:11 +00:00
|
|
|
char *d_name;
|
|
|
|
long startcluster;
|
|
|
|
};
|
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
typedef struct {
|
|
|
|
bool busy;
|
2010-02-16 22:49:11 +00:00
|
|
|
struct dirent_cached theent; /* .attribute is set to -1 on init(opendir) */
|
2011-06-20 20:12:42 +00:00
|
|
|
int internal_entry; /* the current entry in the directory */
|
2007-07-20 17:06:55 +00:00
|
|
|
DIR_UNCACHED *regulardir;
|
|
|
|
} DIR_CACHED;
|
2005-10-07 17:38:05 +00:00
|
|
|
|
2010-03-03 23:20:32 +00:00
|
|
|
void dircache_init(void) INIT_ATTR;
|
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);
|
2011-08-14 15:13:00 +00:00
|
|
|
void* dircache_steal_buffer(size_t *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);
|
2011-06-20 20:12:42 +00:00
|
|
|
int dircache_get_entry_id(const char *filename);
|
|
|
|
size_t dircache_copy_path(int index, char *buf, size_t size);
|
|
|
|
|
|
|
|
/* the next two are internal for file.c */
|
|
|
|
long _dircache_get_entry_startcluster(int id);
|
|
|
|
struct dirinfo* _dircache_get_entry_dirinfo(int id);
|
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);
|
2010-02-16 22:49:11 +00:00
|
|
|
struct dirent_cached* readdir_cached(DIR_CACHED* dir);
|
2007-07-20 17:06:55 +00:00
|
|
|
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
|