[Scummvm-git-logs] scummvm master -> 384968ced20618e593523477b18afee19786896c

AndywinXp noreply at scummvm.org
Fri Oct 4 10:40:16 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
384968ced2 COMMON: Add getResLength() to MacResManager


Commit: 384968ced20618e593523477b18afee19786896c
    https://github.com/scummvm/scummvm/commit/384968ced20618e593523477b18afee19786896c
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-10-04T12:40:12+02:00

Commit Message:
COMMON: Add getResLength() to MacResManager

Changed paths:
    common/macresman.cpp
    common/macresman.h


diff --git a/common/macresman.cpp b/common/macresman.cpp
index 8a26d448b2a..6b315c4e5a3 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -948,6 +948,34 @@ SeekableReadStream *MacResManager::getResource(uint32 typeID, const String &file
 	return nullptr;
 }
 
+uint32 MacResManager::getResLength(uint32 typeID, uint16 resID) {
+	int typeNum = -1;
+	int resNum = -1;
+
+	for (int i = 0; i < _resMap.numTypes; i++)
+		if (_resTypes[i].id == typeID) {
+			typeNum = i;
+			break;
+		}
+
+	if (typeNum == -1)
+		return 0;
+
+	for (int i = 0; i < _resTypes[typeNum].items; i++)
+		if (_resLists[typeNum][i].id == resID) {
+			resNum = i;
+			break;
+		}
+
+	if (resNum == -1)
+		return 0;
+
+	_stream->seek(_dataOffset + _resLists[typeNum][resNum].dataOffset);
+	uint32 len = _stream->readUint32BE();
+
+	return len;
+}
+
 void MacResManager::readMap() {
 	_stream->seek(_mapOffset + 22);
 
diff --git a/common/macresman.h b/common/macresman.h
index 10f8188a97f..8fe49e45492 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -240,6 +240,14 @@ public:
 	 */
 	String getResName(uint32 typeID, uint16 resID) const;
 
+	/**
+	 * Get the length in bytes of a given resource
+	 * @param typeID FourCC of the type
+	 * @param resID Resource ID to fetch
+	 * @return The length in bytes of a given resource
+	 */
+	uint32 getResLength(uint32 typeID, uint16 resID);
+
 	/**
 	 * Get the size of the data portion of the resource fork
 	 * @return The size of the data portion of the resource fork




More information about the Scummvm-git-logs mailing list