diff --git a/cfile/cfile.cpp b/cfile/cfile.cpp index d3dc9335..275d3366 100644 --- a/cfile/cfile.cpp +++ b/cfile/cfile.cpp @@ -35,7 +35,6 @@ #include "log.h" #include "mem.h" #include "pserror.h" -#include "psglob.h" // Library structures struct library_entry { @@ -943,81 +942,6 @@ uint32_t cf_GetfileCRC(const std::filesystem::path &src) { return crc; } -char cfile_search_wildcard[256]; -std::shared_ptr cfile_search_library; -int cfile_search_curr_index = 0; -bool cfile_search_ispattern = false; -// 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. -bool cf_LibraryFindFirst(int handle, const char *wildcard, char *buffer) { - ASSERT(wildcard); - ASSERT(buffer); - if (!wildcard || !buffer) - return false; - *buffer = '\0'; - if (cfile_search_library) - cf_LibraryFindClose(); - // find the library - cfile_search_library = Libraries; - while (cfile_search_library && cfile_search_library->handle != handle) { - cfile_search_library = cfile_search_library->next; - } - if (!cfile_search_library) - return false; - // now find the first matching file - strncpy(cfile_search_wildcard, wildcard, 255); - cfile_search_wildcard[255] = '\0'; - cfile_search_ispattern = (bool)(PSGlobHasPattern(cfile_search_wildcard) != 0); - cfile_search_curr_index = 0; - - while (cfile_search_curr_index < cfile_search_library->nfiles) { - if (cfile_search_ispattern) { - if (PSGlobMatch(cfile_search_wildcard, cfile_search_library->entries[cfile_search_curr_index]->name, 0, 0)) { - // it's a match - strcpy(buffer, cfile_search_library->entries[cfile_search_curr_index]->name); - cfile_search_curr_index++; - return true; - } - } else { - if (!stricmp(cfile_search_library->entries[cfile_search_curr_index]->name, cfile_search_wildcard)) { - strcpy(buffer, cfile_search_library->entries[cfile_search_curr_index]->name); - cfile_search_curr_index++; - return true; - } - } - cfile_search_curr_index++; - } - // we didn't find a match - return false; -} - -bool cf_LibraryFindNext(char *buffer) { - while (cfile_search_curr_index < cfile_search_library->nfiles) { - if (cfile_search_ispattern) { - if (PSGlobMatch(cfile_search_wildcard, cfile_search_library->entries[cfile_search_curr_index]->name, 0, 0)) { - // it's a match - strcpy(buffer, cfile_search_library->entries[cfile_search_curr_index]->name); - cfile_search_curr_index++; - return true; - } - } else { - if (!stricmp(cfile_search_library->entries[cfile_search_curr_index]->name, cfile_search_wildcard)) { - strcpy(buffer, cfile_search_library->entries[cfile_search_curr_index]->name); - cfile_search_curr_index++; - return true; - } - } - cfile_search_curr_index++; - } - return false; -} - -void cf_LibraryFindClose() { - cfile_search_library = nullptr; - cfile_search_curr_index = 0; - cfile_search_ispattern = false; -} - int cf_DoForeachFileInLibrary(int handle, const std::filesystem::path &ext, const std::function &func) { auto search_library = Libraries; diff --git a/cfile/cfile.h b/cfile/cfile.h index 91a2f4b0..7c51d189 100644 --- a/cfile/cfile.h +++ b/cfile/cfile.h @@ -101,8 +101,6 @@ #include #include -#include "pstypes.h" - struct library; // The structure for a CFILE @@ -328,12 +326,6 @@ void cf_Rewind(CFILE *fp); uint32_t cf_GetfileCRC(const std::filesystem::path &src); uint32_t cf_CalculateFileCRC(CFILE *fp); // same as cf_GetfileCRC, except works with CFILE pointers -// 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. -bool cf_LibraryFindFirst(int handle, const char *wildcard, char *buffer); -bool cf_LibraryFindNext(char *buffer); -void cf_LibraryFindClose(); - /** * Execute function for each file in lib that matches to extension. * @param handle library handle where to search diff --git a/misc/psglob.cpp b/misc/psglob.cpp index cae5d53d..4e210cbe 100644 --- a/misc/psglob.cpp +++ b/misc/psglob.cpp @@ -43,33 +43,6 @@ #include #endif -// Returns 1 if string contains globbing characters in it -int PSGlobHasPattern(char *string) { - char *p = string; - char c; - int open = 0; - - while ((c = *p++) != '\0') { - switch (c) { - case '?': - case '*': - return 1; - case '[': // Open brackets must have a matching close bracket in order to be a glob - open++; - continue; - case ']': - if (open) - return 1; - continue; - case '\\': - if (*p++ == '\0') - return 0; - } - } - - return 0; -} - // PSGlobMatch // Matches the pattern passed in to the string in text. If the pattern matches // it returns 1, if not, it returns 0. In order to have a match, the following diff --git a/misc/psglob.h b/misc/psglob.h index 6b2f0195..cff3d266 100644 --- a/misc/psglob.h +++ b/misc/psglob.h @@ -37,9 +37,6 @@ #ifndef __PSGLOB_H_ #define __PSGLOB_H_ -// Returns 1 if string contains globbing characters in it -int PSGlobHasPattern(char *string); - // PSGlobMatch // Matches the pattern passed in to the string in text. If the pattern matches // it returns 1, if not, it returns 0. In order to have a match, the following