aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNipun Garg2019-06-07 16:13:50 +0530
committerEugene Sandulenko2019-09-03 17:16:44 +0200
commit846d799b19c41963ec2ad9c3324392e57a5f23c0 (patch)
tree20cebbc84ef5aca1eb9ab2a514c12c6ff8db5dee
parent8e62d001fcb4bf4f789d578e5b0771cc8d064b24 (diff)
downloadscummvm-rg350-846d799b19c41963ec2ad9c3324392e57a5f23c0.tar.gz
scummvm-rg350-846d799b19c41963ec2ad9c3324392e57a5f23c0.tar.bz2
scummvm-rg350-846d799b19c41963ec2ad9c3324392e57a5f23c0.zip
HDB: Add getCount to FileMan
It counts the number of MPC entries that have a specific substring in their filename
-rw-r--r--engines/hdb/file-manager.cpp27
-rw-r--r--engines/hdb/file-manager.h10
2 files changed, 17 insertions, 20 deletions
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index daa4a89e6b..603c11b970 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -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
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index f50bfc31e4..db04ce4e1b 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -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);
};