1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef GLK_FROTZ_SOUND_FOLDER_H 24 #define GLK_FROTZ_SOUND_FOLDER_H 25 26 #include "glk/frotz/frotz_types.h" 27 #include "common/archive.h" 28 #include "common/fs.h" 29 #include "common/hash-str.h" 30 31 namespace Glk { 32 namespace Frotz { 33 34 /** 35 * Acts as an interface to an Infocom sound subfolder for the Lurking Horror or 36 * Sherlock. Any file which ends with a number and '.snd' will be accessible as 37 * 'sound<num>.snd' in the outer Glk layer 38 */ 39 class SoundSubfolder : public Common::Archive { 40 private: 41 Common::FSNode _folder; 42 Common::StringMap _filenames; 43 private: 44 /** 45 * Constructor 46 */ 47 SoundSubfolder(const Common::FSNode &folder); 48 public: 49 /** 50 * Checks for a sound subfolder, and if so, instantiates the class for it 51 */ 52 static void check(const Common::FSNode &gameDir); 53 54 /** 55 * Check if a member with the given name is present in the Archive. 56 * Patterns are not allowed, as this is meant to be a quick File::exists() 57 * replacement. 58 */ 59 virtual bool hasFile(const Common::String &name) const override; 60 61 /** 62 * Add all members of the Archive to list. 63 * Must only append to list, and not remove elements from it. 64 * 65 * @return the number of names added to list 66 */ 67 virtual int listMembers(Common::ArchiveMemberList &list) const override; 68 69 /** 70 * Returns a ArchiveMember representation of the given file. 71 */ 72 virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const override; 73 74 /** 75 * Create a stream bound to a member with the specified name in the 76 * archive. If no member with this name exists, 0 is returned. 77 * @return the newly created input stream 78 */ 79 virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const override; 80 }; 81 82 /** 83 * Acts as an interface to a Zip file from if-archive for the Lurking Horror or 84 * Sherlock. Any file which ends with a number and '.snd' will be accessible as 85 * 'sound<num>.snd' in the outer Glk layer 86 */ 87 class SoundZip : public Common::Archive { 88 private: 89 Common::Archive *_zip; 90 Common::StringMap _filenames; 91 private: 92 /** 93 * Constructor 94 */ 95 SoundZip(Common::Archive *zip); 96 public: 97 /** 98 * Checks for a sound subfolder, and if so, instantiates the class for it 99 */ 100 static void check(const Common::FSNode &gameDir, Story story); 101 102 /** 103 * Destructor 104 */ 105 ~SoundZip(); 106 107 /** 108 * Check if a member with the given name is present in the Archive. 109 * Patterns are not allowed, as this is meant to be a quick File::exists() 110 * replacement. 111 */ 112 virtual bool hasFile(const Common::String &name) const override; 113 114 /** 115 * Add all members of the Archive to list. 116 * Must only append to list, and not remove elements from it. 117 * 118 * @return the number of names added to list 119 */ 120 virtual int listMembers(Common::ArchiveMemberList &list) const override; 121 122 /** 123 * Returns a ArchiveMember representation of the given file. 124 */ 125 virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const override; 126 127 /** 128 * Create a stream bound to a member with the specified name in the 129 * archive. If no member with this name exists, 0 is returned. 130 * @return the newly created input stream 131 */ 132 virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const override; 133 }; 134 135 } // End of namespace Frotz 136 } // End of namespace Glk 137 138 #endif 139