Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 1 | #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 | */ |
| 20 | typedef enum { |
| 21 | DCET_FREE, |
| 22 | DCET_USED, |
| 23 | DCET_END |
| 24 | } dirCacheEntryType_t; |
| 25 | |
| 26 | #define DC_BITMAP_SIZE 128 |
| 27 | |
| 28 | typedef struct dirCacheEntry_t dirCacheEntry_t; |
| 29 | |
| 30 | typedef 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 | |
| 39 | int isHashed(dirCache_t *cache, wchar_t *name); |
| 40 | int growDirCache(dirCache_t *cache, unsigned int slot); |
| 41 | dirCache_t *allocDirCache(Stream_t *Stream, unsigned int slot); |
| 42 | dirCacheEntry_t *addUsedEntry(dirCache_t *Stream, |
| 43 | unsigned int begin, |
| 44 | unsigned int end, |
| 45 | wchar_t *longName, wchar_t *shortName, |
| 46 | struct directory *dir); |
| 47 | void freeDirCache(Stream_t *Stream); |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame^] | 48 | dirCacheEntry_t *addFreeEntry(dirCache_t *Stream, |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 49 | unsigned int begin, unsigned int end); |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame^] | 50 | dirCacheEntry_t *addFreeEndEntry(dirCache_t *Stream, |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 51 | unsigned int begin, unsigned int end, |
| 52 | int isAtEnd); |
| 53 | dirCacheEntry_t *addEndEntry(dirCache_t *Stream, unsigned int pos); |
| 54 | dirCacheEntry_t *lookupInDircache(dirCache_t *Stream, unsigned int pos); |
| 55 | #endif |