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