ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

macresman.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00033 #include "common/array.h"
00034 #include "common/fs.h"
00035 #include "common/str.h"
00036 #include "common/str-array.h"
00037 
00038 #ifndef COMMON_MACRESMAN_H
00039 #define COMMON_MACRESMAN_H
00040 
00041 namespace Common {
00042 
00043 typedef Array<uint16> MacResIDArray;
00044 typedef Array<uint32> MacResTagArray;
00045 
00050 class MacResManager {
00051 
00052 public:
00053     MacResManager();
00054     ~MacResManager();
00055 
00066     bool open(const String &fileName);
00067 
00076     bool open(const FSNode &path, const String &fileName);
00077 
00083     static bool exists(const String &fileName);
00084 
00093     static void listFiles(StringArray &files, const String &pattern);
00094 
00098     void close();
00099 
00104     bool hasDataFork() const;
00105 
00110     bool hasResFork() const;
00111 
00118     SeekableReadStream *getResource(uint32 typeID, uint16 resID);
00119 
00126     SeekableReadStream *getResource(const String &filename);
00127 
00134     SeekableReadStream *getResource(uint32 typeID, const String &filename);
00135 
00140     SeekableReadStream *getDataFork();
00141 
00148     String getResName(uint32 typeID, uint16 resID) const;
00149 
00154     uint32 getResForkDataSize() const;
00155 
00161     String computeResForkMD5AsString(uint32 length = 0) const;
00162 
00167     String getBaseFileName() const { return _baseFileName; }
00168 
00172     MacResIDArray getResIDArray(uint32 typeID);
00173 
00177     MacResTagArray getResTagArray();
00178 
00182     bool loadFromMacBinary(SeekableReadStream &stream);
00183 
00184 private:
00185     SeekableReadStream *_stream;
00186     String _baseFileName;
00187 
00188     bool load(SeekableReadStream &stream);
00189 
00190     bool loadFromRawFork(SeekableReadStream &stream);
00191     bool loadFromAppleDouble(SeekableReadStream &stream);
00192 
00193     static String constructAppleDoubleName(String name);
00194     static String disassembleAppleDoubleName(String name, bool *isAppleDouble);
00195 
00200     static bool isMacBinary(SeekableReadStream &stream);
00201 
00207     static bool isRawFork(SeekableReadStream &stream);
00208 
00209     enum {
00210         kResForkNone = 0,
00211         kResForkRaw,
00212         kResForkMacBinary,
00213         kResForkAppleDouble
00214     } _mode;
00215 
00216     void readMap();
00217 
00218     struct ResMap {
00219         uint16 resAttr;
00220         uint16 typeOffset;
00221         uint16 nameOffset;
00222         uint16 numTypes;
00223     };
00224 
00225     struct ResType {
00226         uint32 id;
00227         uint16 items;
00228         uint16 offset;
00229     };
00230 
00231     struct Resource {
00232         uint16 id;
00233         int16 nameOffset;
00234         byte attr;
00235         uint32 dataOffset;
00236         char *name;
00237     };
00238 
00239     typedef Resource *ResPtr;
00240 
00241     int32 _resForkOffset;
00242     uint32 _resForkSize;
00243 
00244     uint32 _dataOffset;
00245     uint32 _dataLength;
00246     uint32 _mapOffset;
00247     uint32 _mapLength;
00248     ResMap _resMap;
00249     ResType *_resTypes;
00250     ResPtr  *_resLists;
00251 };
00252 
00253 } // End of namespace Common
00254 
00255 #endif


Generated on Sat Mar 16 2019 05:01:44 for ResidualVM by doxygen 1.7.1
curved edge   curved edge