MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / DoStorageSearch

Function DoStorageSearch

src/External/CascLib/src/CascFindFile.cpp:154–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154static bool DoStorageSearch(TCascSearch * pSearch, PCASC_FIND_DATA pFindData)
155{
156 // State 0: No search done yet
157 if(pSearch->nSearchState == 0)
158 {
159 // Does the search specify listfile?
160 if(pSearch->szListFile != NULL)
161 pSearch->pCache = ListFile_OpenExternal(pSearch->szListFile);
162
163 // Move the search phase to the listfile searching
164 pSearch->nSearchState = 1;
165 pSearch->nFileIndex = 0;
166 }
167
168 // State 1: Searching the list file
169 if(pSearch->nSearchState == 1)
170 {
171 if(DoStorageSearch_RootFile(pSearch, pFindData))
172 return true;
173
174 // Move to the nameless search state
175 pSearch->nSearchState = 2;
176 pSearch->nFileIndex = 0;
177 }
178
179 // State 2: Searching the remaining entries by CKey
180 if(pSearch->nSearchState == 2 && (pSearch->szMask == NULL || !strcmp(pSearch->szMask, "*")))
181 {
182 if(DoStorageSearch_CKey(pSearch, pFindData))
183 return true;
184
185 // Move to the final search state
186 pSearch->nSearchState++;
187 pSearch->nFileIndex = 0;
188 }
189
190 return false;
191}
192
193//-----------------------------------------------------------------------------
194// Public functions

Callers 2

CascFindFirstFileFunction · 0.85
CascFindNextFileFunction · 0.85

Calls 3

ListFile_OpenExternalFunction · 0.85
DoStorageSearch_RootFileFunction · 0.85
DoStorageSearch_CKeyFunction · 0.85

Tested by

no test coverage detected