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 
00187      void dumpRaw();
00188 
00189 private:
00190     SeekableReadStream *_stream;
00191     String _baseFileName;
00192 
00193     bool load(SeekableReadStream &stream);
00194 
00195     bool loadFromRawFork(SeekableReadStream &stream);
00196     bool loadFromAppleDouble(SeekableReadStream &stream);
00197 
00198     static String constructAppleDoubleName(String name);
00199     static String disassembleAppleDoubleName(String name, bool *isAppleDouble);
00200 
00205     static bool isMacBinary(SeekableReadStream &stream);
00206 
00212     static bool isRawFork(SeekableReadStream &stream);
00213 
00214     enum {
00215         kResForkNone = 0,
00216         kResForkRaw,
00217         kResForkMacBinary,
00218         kResForkAppleDouble
00219     } _mode;
00220 
00221     void readMap();
00222 
00223     struct ResMap {
00224         uint16 resAttr;
00225         uint16 typeOffset;
00226         uint16 nameOffset;
00227         uint16 numTypes;
00228 
00229         void reset() {
00230             resAttr = 0;
00231             typeOffset = 0;
00232             nameOffset = 0;
00233             numTypes = 0;
00234         }
00235 
00236         ResMap() { reset(); }
00237     };
00238 
00239     struct ResType {
00240         uint32 id;
00241         uint16 items;
00242         uint16 offset;
00243     };
00244 
00245     struct Resource {
00246         uint16 id;
00247         int16 nameOffset;
00248         byte attr;
00249         uint32 dataOffset;
00250         char *name;
00251     };
00252 
00253     typedef Resource *ResPtr;
00254 
00255     int32 _resForkOffset;
00256     uint32 _resForkSize;
00257 
00258     uint32 _dataOffset;
00259     uint32 _dataLength;
00260     uint32 _mapOffset;
00261     uint32 _mapLength;
00262     ResMap _resMap;
00263     ResType *_resTypes;
00264     ResPtr  *_resLists;
00265 };
00266 
00267 } // End of namespace Common
00268 
00269 #endif


Generated on Sat May 30 2020 05:00:39 for ResidualVM by doxygen 1.7.1
curved edge   curved edge