3 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials are licensed and made available
5 under the terms and conditions of the BSD License which accompanies this
6 distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 IN CHAR16
*LongNameString
36 Get hash value for long name.
40 LongNameString - The long name string to be hashed.
49 CHAR16 UpCasedLongFileName
[EFI_PATH_STRING_LENGTH
];
50 StrnCpy (UpCasedLongFileName
, LongNameString
, EFI_PATH_STRING_LENGTH
- 1);
51 UpCasedLongFileName
[EFI_PATH_STRING_LENGTH
- 1] = L
'\0';
52 FatStrUpr (UpCasedLongFileName
);
53 gBS
->CalculateCrc32 (UpCasedLongFileName
, StrSize (UpCasedLongFileName
), &HashValue
);
54 return (HashValue
& HASH_TABLE_MASK
);
60 IN CHAR8
*ShortNameString
66 Get hash value for short name.
70 ShortNameString - The short name string to be hashed.
79 gBS
->CalculateCrc32 (ShortNameString
, FAT_NAME_LEN
, &HashValue
);
80 return (HashValue
& HASH_TABLE_MASK
);
84 FatLongNameHashSearch (
86 IN CHAR16
*LongNameString
92 Search the long name hash table for the directory entry.
96 ODir - The directory to be searched.
97 LongNameString - The long name string to search.
101 The previous long name hash node of the directory entry.
105 FAT_DIRENT
**PreviousHashNode
;
106 for (PreviousHashNode
= &ODir
->LongNameHashTable
[FatHashLongName (LongNameString
)];
107 *PreviousHashNode
!= NULL
;
108 PreviousHashNode
= &(*PreviousHashNode
)->LongNameForwardLink
110 if (FatStriCmp (LongNameString
, (*PreviousHashNode
)->FileString
) == 0) {
115 return PreviousHashNode
;
119 FatShortNameHashSearch (
121 IN CHAR8
*ShortNameString
127 Search the short name hash table for the directory entry.
131 ODir - The directory to be searched.
132 ShortNameString - The short name string to search.
136 The previous short name hash node of the directory entry.
140 FAT_DIRENT
**PreviousHashNode
;
141 for (PreviousHashNode
= &ODir
->ShortNameHashTable
[FatHashShortName (ShortNameString
)];
142 *PreviousHashNode
!= NULL
;
143 PreviousHashNode
= &(*PreviousHashNode
)->ShortNameForwardLink
145 if (CompareMem (ShortNameString
, (*PreviousHashNode
)->Entry
.FileName
, FAT_NAME_LEN
) == 0) {
150 return PreviousHashNode
;
154 FatInsertToHashTable (
156 IN FAT_DIRENT
*DirEnt
162 Insert directory entry to hash table.
166 ODir - The parent directory.
167 DirEnt - The directory entry node.
175 FAT_DIRENT
**HashTable
;
176 UINT32 HashTableIndex
;
179 // Insert hash table index for short name
181 HashTableIndex
= FatHashShortName (DirEnt
->Entry
.FileName
);
182 HashTable
= ODir
->ShortNameHashTable
;
183 DirEnt
->ShortNameForwardLink
= HashTable
[HashTableIndex
];
184 HashTable
[HashTableIndex
] = DirEnt
;
186 // Insert hash table index for long name
188 HashTableIndex
= FatHashLongName (DirEnt
->FileString
);
189 HashTable
= ODir
->LongNameHashTable
;
190 DirEnt
->LongNameForwardLink
= HashTable
[HashTableIndex
];
191 HashTable
[HashTableIndex
] = DirEnt
;
195 FatDeleteFromHashTable (
197 IN FAT_DIRENT
*DirEnt
203 Delete directory entry from hash table.
207 ODir - The parent directory.
208 DirEnt - The directory entry node.
216 *FatShortNameHashSearch (ODir
, DirEnt
->Entry
.FileName
) = DirEnt
->ShortNameForwardLink
;
217 *FatLongNameHashSearch (ODir
, DirEnt
->FileString
) = DirEnt
->LongNameForwardLink
;