2
Copyright (C) 2009- The University of Notre Dame
3
This software is distributed under the GNU General Public License.
4
See the file COPYING for details.
7
#include "pfs_dircache.h"
12
#include "hash_table.h"
13
#include "stringtools.h"
23
pfs_dircache::pfs_dircache()
29
pfs_dircache::~pfs_dircache()
34
hash_table_delete(dircache_table);
40
void pfs_dircache::invalidate()
46
hash_table_firstkey(dircache_table);
47
while (hash_table_nextkey(dircache_table, &key, &value)) {
48
hash_table_remove(dircache_table, key);
59
void pfs_dircache::begin( const char *path )
62
dircache_path = xstrdup(path);
65
void pfs_dircache::insert( const char *name, struct pfs_stat *buf, pfs_dir *dir )
67
char path[PFS_PATH_MAX];
68
struct pfs_stat *copy;
70
if (!dircache_table) dircache_table = hash_table_create(0, 0);
74
copy = (struct pfs_stat *)xxmalloc(sizeof(struct pfs_stat));
77
sprintf(path, "%s/%s", dircache_path, string_basename(name));
78
hash_table_insert(dircache_table, path, copy);
81
int pfs_dircache::lookup( const char *path, struct pfs_stat *buf )
83
struct pfs_stat *value;
86
if (!dircache_table) dircache_table = hash_table_create(0, 0);
88
value = (struct pfs_stat *)hash_table_lookup(dircache_table, path);
91
hash_table_remove(dircache_table, path);
99
// vim: ts=8 st=8 sw=8 ft=cpp