blob: 161c9a563198089ede2df6d6ebcab0012e4dfee8 [file] [log] [blame]
Alistair Delvabeaee832021-02-24 11:27:23 -08001#ifndef MTOOLS_DIRCACHE_H
2#define MTOOLS_DIRCACHE_H
3
4/* Copyright 1997,1999,2001-2003,2008,2009 Alain Knaff.
5 * This file is part of mtools.
6 *
7 * Mtools is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Mtools is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Mtools. If not, see <http://www.gnu.org/licenses/>.
19 */
20typedef enum {
21 DCET_FREE,
22 DCET_USED,
23 DCET_END
24} dirCacheEntryType_t;
25
26#define DC_BITMAP_SIZE 128
27
28typedef struct dirCacheEntry_t dirCacheEntry_t;
29
30typedef struct dirCache_t {
31 struct dirCacheEntry_t **entries;
32 unsigned int nr_entries;
33 unsigned int nrHashed;
34 unsigned int bm0[DC_BITMAP_SIZE];
35 unsigned int bm1[DC_BITMAP_SIZE];
36 unsigned int bm2[DC_BITMAP_SIZE];
37} dirCache_t;
38
39int isHashed(dirCache_t *cache, wchar_t *name);
40int growDirCache(dirCache_t *cache, unsigned int slot);
41dirCache_t *allocDirCache(Stream_t *Stream, unsigned int slot);
42dirCacheEntry_t *addUsedEntry(dirCache_t *Stream,
43 unsigned int begin,
44 unsigned int end,
45 wchar_t *longName, wchar_t *shortName,
46 struct directory *dir);
47void freeDirCache(Stream_t *Stream);
Yi Kong39bbd962022-01-09 19:41:38 +080048dirCacheEntry_t *addFreeEntry(dirCache_t *Stream,
Alistair Delvabeaee832021-02-24 11:27:23 -080049 unsigned int begin, unsigned int end);
Yi Kong39bbd962022-01-09 19:41:38 +080050dirCacheEntry_t *addFreeEndEntry(dirCache_t *Stream,
Alistair Delvabeaee832021-02-24 11:27:23 -080051 unsigned int begin, unsigned int end,
52 int isAtEnd);
53dirCacheEntry_t *addEndEntry(dirCache_t *Stream, unsigned int pos);
54dirCacheEntry_t *lookupInDircache(dirCache_t *Stream, unsigned int pos);
55#endif