mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Remove unused cf_LibraryFindFirst() and related to it functions
This commit is contained in:
parent
6f81ca4f9f
commit
245f9c6425
@ -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<library> 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<void(std::filesystem::path)> &func) {
|
||||
auto search_library = Libraries;
|
||||
|
@ -101,8 +101,6 @@
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#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
|
||||
|
@ -43,33 +43,6 @@
|
||||
#include <ctype.h>
|
||||
#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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user