HDB: Add getCount to FileMan

It counts the number of MPC entries that have
a specific substring in their filename
This commit is contained in:
Nipun Garg 2019-06-07 16:13:50 +05:30 committed by Eugene Sandulenko
parent 8e62d001fc
commit 846d799b19
2 changed files with 17 additions and 20 deletions

View File

@ -143,6 +143,22 @@ int32 FileMan::getLength(const char *string, DataType type) {
return file->ulength;
}
int FileMan::getCount(char *subString, DataType type) {
int count = 0;
Common::String fileString;
for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
fileString = (*it)->filename;
if (fileString.contains(subString)) {
if ((*it)->type == type) {
count++;
}
}
}
return count;
}
#if 0
MPCEntry **FileMan::findNextData(MPCIterator begin) {
Common::String fileString;
@ -158,17 +174,6 @@ MPCEntry **FileMan::findNextData(MPCIterator begin) {
return NULL;
}
int FileMan::findAmount(char *string, DataType type) {
int count = 0;
MPCIterator it = findFirstData(string, type);
while (it && (*it)->type == type) {
count++;
it = findNextData(it);
}
return count;
}
#endif
} // End of Namespace HDB

View File

@ -76,17 +76,9 @@ public:
void closeMPC();
void seek(int32 offset, int flag);
/*
TODO: Implement the loadData functions for the various
DataTypes as they are encountered.
void loadData(char *string, uint32 *length);
*/
Common::SeekableReadStream *findFirstData(const char *string, DataType type);
int32 getLength(const char *string, DataType type);
//MPCEntry **findNextData(MPCIterator it);
//int findAmount(char *string, DataType type);
int getCount(char *subString, DataType type);
};