MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / cf_LibraryFindFirst

Function cf_LibraryFindFirst

cfile/cfile.cpp:964–1004  ·  view source on GitHub ↗

the following cf_LibraryFind function are similar to the ddio_Find functions as they look for files that match the wildcard passed in, however, this is to be used for hog files.

Source from the content-addressed store, hash-verified

962// the following cf_LibraryFind function are similar to the ddio_Find functions as they look
963// for files that match the wildcard passed in, however, this is to be used for hog files.
964bool cf_LibraryFindFirst(int handle, const char *wildcard, char *buffer) {
965 ASSERT(wildcard);
966 ASSERT(buffer);
967 if (!wildcard || !buffer)
968 return false;
969 *buffer = '\0';
970 if (cfile_search_library)
971 cf_LibraryFindClose();
972 // find the library
973 cfile_search_library = Libraries;
974 while (cfile_search_library && cfile_search_library->handle != handle) {
975 cfile_search_library = cfile_search_library->next;
976 }
977 if (!cfile_search_library)
978 return false;
979 // now find the first matching file
980 strncpy(cfile_search_wildcard, wildcard, 255);
981 cfile_search_wildcard[255] = '\0';
982 cfile_search_ispattern = (bool)(PSGlobHasPattern(cfile_search_wildcard) != 0);
983 cfile_search_curr_index = 0;
984
985 while (cfile_search_curr_index < cfile_search_library->nfiles) {
986 if (cfile_search_ispattern) {
987 if (PSGlobMatch(cfile_search_wildcard, cfile_search_library->entries[cfile_search_curr_index]->name, 0, 0)) {
988 // it's a match
989 strcpy(buffer, cfile_search_library->entries[cfile_search_curr_index]->name);
990 cfile_search_curr_index++;
991 return true;
992 }
993 } else {
994 if (!stricmp(cfile_search_library->entries[cfile_search_curr_index]->name, cfile_search_wildcard)) {
995 strcpy(buffer, cfile_search_library->entries[cfile_search_curr_index]->name);
996 cfile_search_curr_index++;
997 return true;
998 }
999 }
1000 cfile_search_curr_index++;
1001 }
1002 // we didn't find a match
1003 return false;
1004}
1005
1006bool cf_LibraryFindNext(char *buffer) {
1007 while (cfile_search_curr_index < cfile_search_library->nfiles) {

Callers 1

Calls 3

cf_LibraryFindCloseFunction · 0.85
PSGlobHasPatternFunction · 0.85
PSGlobMatchFunction · 0.85

Tested by

no test coverage detected