int ResourceManager::listMembers(Common::ArchiveMemberList &list) const { int count = 0; for (Common::Array<HPFArchive *>::const_iterator it = _archives.begin(); it != _archives.end(); ++it) { Common::ArchiveMemberList members; count += (*it)->listMembers(members); list.insert(list.end(), members.begin(), members.end()); } return count; }
void Music::getSongNames(Common::StringArray &songs) { songs.clear(); if (IS_SERRATED_SCALPEL) { if (IS_3DO) { Common::FSDirectory gameDirectory(ConfMan.get("path")); Common::FSDirectory *musicDirectory = gameDirectory.getSubDirectory("music"); Common::ArchiveMemberList files; musicDirectory->listMatchingMembers(files, "*_mw22.aifc"); for (Common::ArchiveMemberList::iterator i = files.begin(); i != files.end(); ++i) { Common::String name = (*i)->getName(); name.erase(name.size() - 10); songs.push_back(name); } } else { for (int i = 0; i < ARRAYSIZE(SONG_NAMES); i++) { songs.push_back(SONG_NAMES[i]); } } } else { Common::StringArray fileList; _vm->_res->getResourceNames("music.lib", fileList); for (Common::StringArray::iterator i = fileList.begin(); i != fileList.end(); ++i) { if ((*i).matchString("*.XMI", true)) { (*i).erase((*i).size() - 4); songs.push_back(*i); } } } Common::sort(songs.begin(), songs.end()); }
int LangFilter::listMembers(Common::ArchiveMemberList &list) const { if (!_arc) return false; Common::ArchiveMemberList orgList; Common::String orgName, name; _arc->listMembers(orgList); int num = 0; //Search only files with the right language and create a list with their basenames for (Common::ArchiveMemberList::const_iterator it = orgList.begin(); it != orgList.end(); it++) { orgName = (*it)->getName(); if (orgName.hasPrefix(kLanguages1[_lang]) ||orgName.hasPrefix(kLanguages1[kCommon])) name = Common::String(orgName.c_str() + 3); else if (orgName.hasPrefix(kLanguages2[_lang]) || orgName.hasPrefix(kLanguages2[kCommon])) { int i = 0; while (orgName[i++] != '/') {;} name = Common::String(orgName.c_str() + i); //If the file is a subfolder, reject it if (name.contains('/')) continue; } else continue; name.toLowercase(); list.push_back(getMember(name)); ++num; } return num; }
void ThemeEngine::listUsableThemes(Common::Archive &archive, Common::List<ThemeDescriptor> &list) { ThemeDescriptor td; Common::ArchiveMemberList fileList; archive.listMatchingMembers(fileList, "*.zip"); for (Common::ArchiveMemberList::iterator i = fileList.begin(); i != fileList.end(); ++i) { td.name.clear(); if (themeConfigUsable(**i, td.name)) { td.filename = (*i)->getName(); td.id = (*i)->getDisplayName(); // If the name of the node object also contains // the ".zip" suffix, we will strip it. if (td.id.matchString("*.zip", true)) { for (int j = 0; j < 4; ++j) td.id.deleteLastChar(); } list.push_back(td); } } fileList.clear(); }
void Lingo::runTests() { Common::File inFile; Common::ArchiveMemberList fileList; SearchMan.listMatchingMembers(fileList, "*.lingo"); int counter = 1; for (Common::ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) { Common::ArchiveMember const &m = **it; Common::SeekableReadStream *const stream = m.createReadStream(); if (stream) { uint size = stream->size(); char *script = (char *)calloc(size + 1, 1); stream->read(script, size); warning("Compiling file %s of size %d, id: %d", m.getName().c_str(), size, counter); _hadError = false; addCode(script, kMovieScript, counter); if (!_hadError) executeScript(kMovieScript, counter); else warning("Skipping execution"); free(script); counter++; } inFile.close(); } }
ResourceLoader::ResourceLoader() { int lab_counter = 0; _cacheDirty = false; _cacheMemorySize = 0; Lab *l; Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, "*.lab"); SearchMan.listMatchingMembers(files, "*.m4b"); if (files.empty()) error("Cannot find game data - check configuration file"); for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) { const Common::String filename = (*x)->getName(); l = new Lab(); if (l->open(filename)) { if (filename.equalsIgnoreCase("data005.lab")) _labs.push_front(l); else _labs.push_back(l); lab_counter++; } else { delete l; } } files.clear(); if (g_grim->getGameFlags() & GF_DEMO) { SearchMan.listMatchingMembers(files, "*.mus"); for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) { const Common::String filename = (*x)->getName(); l = new Lab(); if (l->open(filename)) { _labs.push_back(l); lab_counter++; } else { delete l; } } } }
int PackageManager::doSearch(Common::ArchiveMemberList &list, const Common::String &filter, const Common::String &path, uint typeFilter) { Common::String normalizedFilter = normalizePath(filter, _currentDirectory); int num = 0; if (path.size() > 0) warning("STUB: PackageManager::doSearch(<%s>, <%s>, %d)", filter.c_str(), path.c_str(), typeFilter); // Loop through checking each archive Common::List<ArchiveEntry *>::iterator i; for (i = _archiveList.begin(); i != _archiveList.end(); ++i) { Common::ArchiveMemberList memberList; if (!normalizedFilter.hasPrefix((*i)->_mountPath)) { // The mount path is in different subtree. Skipping continue; } // Construct relative path Common::String resFilter(&normalizedFilter.c_str()[(*i)->_mountPath.size()]); if ((*i)->archive->listMatchingMembers(memberList, resFilter) == 0) continue; // Create a list of the matching names for (Common::ArchiveMemberList::iterator it = memberList.begin(); it != memberList.end(); ++it) { if (((typeFilter & PackageManager::FT_DIRECTORY) && (*it)->getName().hasSuffix("/")) || ((typeFilter & PackageManager::FT_FILE) && !(*it)->getName().hasSuffix("/"))) { // Do not add duplicate files bool found = false; for (Common::ArchiveMemberList::iterator it1 = list.begin(); it1 != list.end(); ++it1) { if ((*it1)->getName() == (*it)->getName()) { found = true; break; } } if (!found) list.push_back(*it); num++; } } } return num; }
void MacFontManager::loadFontsBDF() { Common::Archive *dat; dat = Common::makeZipArchive("classicmacfonts.dat"); if (!dat) { warning("Could not find classicmacfonts.dat. Falling back to built-in fonts"); _builtInFonts = true; return; } Common::ArchiveMemberList list; dat->listMembers(list); for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) { Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName()); Graphics::BdfFont *font = Graphics::BdfFont::loadFont(*stream); delete stream; Common::String fontName; MacFont *macfont; if (font->getFamilyName() && *font->getFamilyName()) { fontName = Common::String::format("%s-%s-%d", font->getFamilyName(), font->getFontSlant(), font->getFontSize()); macfont = new MacFont(_fontNames.getVal(font->getFamilyName(), kMacFontNonStandard), font->getFontSize(), parseFontSlant(font->getFontSlant())); } else { // Get it from the file name fontName = (*it)->getName(); // Trim the .bdf extension for (int i = fontName.size() - 1; i >= 0; --i) { if (fontName[i] == '.') { while ((uint)i < fontName.size()) { fontName.deleteLastChar(); } break; } } macfont = new MacFont(kMacFontNonStandard); macfont->setName(fontName); } FontMan.assignFontToName(fontName, font); //macfont->setFont(font); _fontRegistry.setVal(fontName, macfont); debug(2, " %s", fontName.c_str()); } _builtInFonts = false; delete dat; }
Common::StringArray Ps2SaveFileManager::listSavefiles(const Common::String &pattern) { Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast? Common::String _dir; Common::String search; bool _mc = (_getDev(savePath) == MC_DEV); // (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0); char *game=0, path[32], temp[32]; if (!savePath.exists() || !savePath.isDirectory()) return Common::StringArray(); printf("listSavefiles = %s\n", pattern.c_str()); if (_mc) { strcpy(temp, pattern.c_str()); // mcSplit(temp, game, ext); game = strdup(strtok(temp, ".")); sprintf(path, "mc0:ScummVM/%s", game); // per game path mcCheck(path); sprintf(path, "mc0:ScummVM/%s/", game); _dir = Common::String(path); search = Common::String("*.sav"); } else { _dir = Common::String(savePath.getPath()); search = pattern; } Common::FSDirectory dir(_dir); Common::ArchiveMemberList savefiles; Common::StringArray results; printf("dir = %s --- reg = %s\n", _dir.c_str(), search.c_str()); if (dir.listMatchingMembers(savefiles, search) > 0) { for (Common::ArchiveMemberList::const_iterator file = savefiles.begin(); file != savefiles.end(); ++file) { if (_mc) { // convert them back in ScummVM names strncpy(temp, (*file)->getName().c_str(), 3); temp[3] = '\0'; sprintf(path, "%s.%s", game, temp); results.push_back(path); printf(" --> found = %s -> %s\n", (*file)->getName().c_str(), path); } else { results.push_back((*file)->getName()); printf(" --> found = %s\n", (*file)->getName().c_str()); } } } free(game); return results; }
bool Console::cmdParseAllScrFiles(int argc, const char **argv) { Common::ArchiveMemberList list; SearchMan.listMatchingMembers(list, "*.scr"); for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { _engine->getScriptManager()->parseScrFile((*iter)->getName()); } return true; }
void ResourceManager::readWaveAudioPatches() { // Here we do check for SCI1.1+ so we can patch wav files in as audio resources Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, "*.wav"); for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) { Common::String name = (*x)->getName(); if (Common::isDigit(name[0])) processWavePatch(ResourceId(kResourceTypeAudio, atoi(name.c_str())), name); } }
bool ThemeEngine::loadThemeXML(const Common::String &themeId) { assert(_parser); assert(_themeArchive); _themeName.clear(); // // Now that we have a Common::Archive, verify that it contains a valid THEMERC File // Common::File themercFile; themercFile.open("THEMERC", *_themeArchive); if (!themercFile.isOpen()) { warning("Theme '%s' contains no 'THEMERC' file.", themeId.c_str()); return false; } Common::String stxHeader = themercFile.readLine(); if (!themeConfigParseHeader(stxHeader, _themeName) || _themeName.empty()) { warning("Corrupted 'THEMERC' file in theme '%s'", themeId.c_str()); return false; } Common::ArchiveMemberList members; if (0 == _themeArchive->listMatchingMembers(members, "*.stx")) { warning("Found no STX files for theme '%s'.", themeId.c_str()); return false; } // // Loop over all STX files, load and parse them // for (Common::ArchiveMemberList::iterator i = members.begin(); i != members.end(); ++i) { assert((*i)->getName().hasSuffix(".stx")); if (_parser->loadStream((*i)->createReadStream()) == false) { warning("Failed to load STX file '%s'", (*i)->getDisplayName().c_str()); _parser->close(); return false; } if (_parser->parse() == false) { warning("Failed to parse STX file '%s'", (*i)->getDisplayName().c_str()); _parser->close(); return false; } _parser->close(); } assert(!_themeName.empty()); return true; }
bool diskFileExists(const Common::String &filename) { // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { if ((*it)->getName() == filename) { return true; } } // File wasn't found in SearchMan, try to parse the path as a relative path. Common::FSNode searchNode = getNodeForRelativePath(filename); if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { return true; } return false; }
bool Console::Cmd_DumpArchive(int argc, const char **argv) { if (argc != 2) { debugPrintf("Extract all the files from a game archive.\n"); debugPrintf("The destination folder, named 'dump', must exist.\n"); debugPrintf("Usage :\n"); debugPrintf("dumpArchive [archive name]\n"); return true; } Formats::XARCArchive xarc; if (!xarc.open(argv[1])) { debugPrintf("Can't open archive with name '%s'\n", argv[1]); return true; } Common::ArchiveMemberList members; xarc.listMembers(members); for (Common::ArchiveMemberList::const_iterator it = members.begin(); it != members.end(); it++) { Common::String fileName = Common::String::format("dump/%s", it->get()->getName().c_str()); // Open the output file Common::DumpFile outFile; if (!outFile.open(fileName)) { debugPrintf("Unable to open file '%s' for writing\n", fileName.c_str()); return true; } // Copy the archive content to the output file using a temporary buffer Common::SeekableReadStream *inStream = it->get()->createReadStream(); uint8 *buf = new uint8[inStream->size()]; inStream->read(buf, inStream->size()); outFile.write(buf, inStream->size()); delete[] buf; delete inStream; outFile.close(); debugPrintf("Extracted '%s'\n", it->get()->getName().c_str()); } return true; }
bool PackageManager::loadPackage(const Common::String &fileName, const Common::String &mountPosition) { debug(3, "loadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str()); Common::Archive *zipFile = Common::makeZipArchive(fileName); if (zipFile == NULL) { BS_LOG_ERRORLN("Unable to mount file \"%s\" to \"%s\"", fileName.c_str(), mountPosition.c_str()); return false; } else { BS_LOGLN("Package '%s' mounted as '%s'.", fileName.c_str(), mountPosition.c_str()); Common::ArchiveMemberList files; zipFile->listMembers(files); debug(3, "Capacity %d", files.size()); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) debug(3, "%s", (*it)->getName().c_str()); _archiveList.push_front(new ArchiveEntry(zipFile, mountPosition)); return true; } }
void Lingo::runTests() { Common::File inFile; Common::ArchiveMemberList fsList; SearchMan.listMatchingMembers(fsList, "*.lingo"); Common::StringArray fileList; int counter = 1; for (Common::ArchiveMemberList::iterator it = fsList.begin(); it != fsList.end(); ++it) fileList.push_back((*it)->getName()); Common::sort(fileList.begin(), fileList.end()); for (uint i = 0; i < fileList.size(); i++) { Common::SeekableReadStream *const stream = SearchMan.createReadStreamForMember(fileList[i]); if (stream) { uint size = stream->size(); char *script = (char *)calloc(size + 1, 1); stream->read(script, size); debugC(2, kDebugLingoCompile, "Compiling file %s of size %d, id: %d", fileList[i].c_str(), size, counter); _hadError = false; addCode(script, kMovieScript, counter); if (!_hadError) executeScript(kMovieScript, counter); else debugC(2, kDebugLingoCompile, "Skipping execution"); free(script); counter++; } inFile.close(); } }
int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) const { if (_hasCached) { member_list.insert(member_list.end(), _cachedMembers.begin(), _cachedMembers.end()); return _cachedMembers.size(); } int count = 0; AAssetDir *dir = AAssetManager_openDir(_am, ""); const char *file = AAssetDir_getNextFileName(dir); while (file) { member_list.push_back(getMember(file)); ++count; file = AAssetDir_getNextFileName(dir); } AAssetDir_close(dir); _cachedMembers = Common::ArchiveMemberList(member_list); _hasCached = true; return count; }
Common::StringArray DefaultSaveFileManager::listSavefiles(const Common::String &pattern) { Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); if (getError().getCode() != Common::kNoError) return Common::StringArray(); // recreate FSNode since checkPath may have changed/created the directory Common::FSNode savePath(savePathName); Common::FSDirectory dir(savePath); Common::ArchiveMemberList savefiles; Common::StringArray results; Common::String search(pattern); if (dir.listMatchingMembers(savefiles, search) > 0) { for (Common::ArchiveMemberList::const_iterator file = savefiles.begin(); file != savefiles.end(); ++file) { results.push_back((*file)->getName()); } } return results; }
bool Resource::reset() { unloadAllPakFiles(); Common::FSNode dir(ConfMan.get("path")); if (!dir.exists() || !dir.isDirectory()) error("invalid game path '%s'", dir.getPath().c_str()); if (_vm->game() == GI_KYRA1) { // We only need kyra.dat for the demo. if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie) return true; if (!_vm->gameFlags().isDemo && _vm->gameFlags().isTalkie) { // List of files in the talkie version, which can never be unload. static const char * const list[] = { "ADL.PAK", "CHAPTER1.VRM", "COL.PAK", "FINALE.PAK", "INTRO1.PAK", "INTRO2.PAK", "INTRO3.PAK", "INTRO4.PAK", "MISC.PAK", "SND.PAK", "STARTUP.PAK", "XMI.PAK", "CAVE.APK", "DRAGON1.APK", "DRAGON2.APK", "LAGOON.APK", 0 }; loadProtectedFiles(list); } else { Common::ArchiveMemberList files; _files.listMatchingMembers(files, "*.PAK"); _files.listMatchingMembers(files, "*.APK"); for (Common::ArchiveMemberList::const_iterator i = files.begin(); i != files.end(); ++i) { Common::String name = (*i)->getName(); name.toUppercase(); // No PAK file if (name == "TWMUSIC.PAK") continue; // We need to only load the script archive for the language the user specified if (name == ((_vm->gameFlags().lang == Common::EN_ANY) ? "JMC.PAK" : "EMC.PAK")) continue; Common::Archive *archive = loadArchive(name, *i); if (archive) _files.add(name, archive, 0, false); else error("Couldn't load PAK file '%s'", name.c_str()); } } } else if (_vm->game() == GI_KYRA2) { if (_vm->gameFlags().useInstallerPackage) _files.add("installer", loadInstallerArchive("WESTWOOD", "%03d", 6), 2, false); // mouse pointer, fonts, etc. required for initialization if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie) { loadPakFile("GENERAL.PAK"); } else { loadPakFile("INTROGEN.PAK"); loadPakFile("OTHER.PAK"); } } else if (_vm->game() == GI_KYRA3) { if (_vm->gameFlags().useInstallerPackage) { if (!loadPakFile("WESTWOOD.001")) error("Couldn't load file: 'WESTWOOD.001'"); } if (!loadFileList("FILEDATA.FDT")) error("Couldn't load file: 'FILEDATA.FDT'"); } else if (_vm->game() == GI_LOL) { if (_vm->gameFlags().useInstallerPackage) _files.add("installer", loadInstallerArchive("WESTWOOD", "%d", 0), 2, false); if (!_vm->gameFlags().isTalkie && !_vm->gameFlags().isDemo) { static const char * const list[] = { "GENERAL.PAK", 0 }; loadProtectedFiles(list); } } else { error("Unknown game id: %d", _vm->game()); return false; // for compilers that don't support NORETURN } return true; }
void dumpEveryResultAction(const Common::String &destFile) { Common::HashMap<Common::String, byte> count; Common::HashMap<Common::String, bool> fileAlreadyUsed; Common::DumpFile output; output.open(destFile); // Find scr files Common::ArchiveMemberList list; SearchMan.listMatchingMembers(list, "*.scr"); for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { Common::SeekableReadStream *stream = (*iter)->createReadStream(); Common::String line = stream->readLine(); trimCommentsAndWhiteSpace(&line); while (!stream->eos()) { if (line.matchString("*:add*", true)) { tryToDumpLine("add", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:animplay*", true)) { tryToDumpLine("animplay", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:animpreload*", true)) { tryToDumpLine("animpreload", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:animunload*", true)) { tryToDumpLine("animunload", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:attenuate*", true)) { tryToDumpLine("attenuate", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:assign*", true)) { tryToDumpLine("assign", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:change_location*", true)) { tryToDumpLine("change_location", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:crossfade*", true) && !fileAlreadyUsed["add"]) { tryToDumpLine("crossfade", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:debug*", true)) { tryToDumpLine("debug", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:delay_render*", true)) { tryToDumpLine("delay_render", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:disable_control*", true)) { tryToDumpLine("disable_control", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:disable_venus*", true)) { tryToDumpLine("disable_venus", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:display_message*", true)) { tryToDumpLine("display_message", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:dissolve*", true)) { tryToDumpLine("dissolve", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:distort*", true)) { tryToDumpLine("distort", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:enable_control*", true)) { tryToDumpLine("enable_control", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:flush_mouse_events*", true)) { tryToDumpLine("flush_mouse_events", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:inventory*", true)) { tryToDumpLine("inventory", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:kill*", true)) { tryToDumpLine("kill", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:menu_bar_enable*", true)) { tryToDumpLine("menu_bar_enable", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:music*", true)) { tryToDumpLine("music", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:pan_track*", true)) { tryToDumpLine("pan_track", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:playpreload*", true)) { tryToDumpLine("playpreload", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:preferences*", true)) { tryToDumpLine("preferences", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:quit*", true)) { tryToDumpLine("quit", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:random*", true)) { tryToDumpLine("random", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:region*", true)) { tryToDumpLine("region", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:restore_game*", true)) { tryToDumpLine("restore_game", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:rotate_to*", true)) { tryToDumpLine("rotate_to", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:save_game*", true)) { tryToDumpLine("save_game", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:set_partial_screen*", true)) { tryToDumpLine("set_partial_screen", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:set_screen*", true)) { tryToDumpLine("set_screen", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:set_venus*", true)) { tryToDumpLine("set_venus", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:stop*", true)) { tryToDumpLine("stop", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:streamvideo*", true)) { tryToDumpLine("streamvideo", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:syncsound*", true)) { tryToDumpLine("syncsound", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:timer*", true)) { tryToDumpLine("timer", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:ttytext*", true)) { tryToDumpLine("ttytext", line, &count, &fileAlreadyUsed, output); } else if (line.matchString("*:universe_music*", true)) { tryToDumpLine("universe_music", line, &count, &fileAlreadyUsed, output); } line = stream->readLine(); trimCommentsAndWhiteSpace(&line); } for (Common::HashMap<Common::String, bool>::iterator fileUsedIter = fileAlreadyUsed.begin(); fileUsedIter != fileAlreadyUsed.end(); ++fileUsedIter) { fileUsedIter->_value = false; } } output.close(); }
void MacFontManager::loadFonts() { Common::Archive *dat; dat = Common::makeZipArchive("classicmacfonts.dat"); if (!dat) { warning("Could not find classicmacfonts.dat. Falling back to built-in fonts"); _builtInFonts = true; return; } Common::ArchiveMemberList list; dat->listMembers(list); for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) { Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName()); Common::MacResManager *fontFile = new Common::MacResManager(); if (!fontFile->loadFromMacBinary(*stream)) continue; Common::MacResIDArray fonds = fontFile->getResIDArray(MKTAG('F','O','N','D')); if (fonds.size() > 0) { for (Common::Array<uint16>::iterator iterator = fonds.begin(); iterator != fonds.end(); ++iterator) { Common::SeekableReadStream *fond = fontFile->getResource(MKTAG('F', 'O', 'N', 'D'), *iterator); Common::String familyName = fontFile->getResName(MKTAG('F', 'O', 'N', 'D'), *iterator); Graphics::MacFontFamily *fontFamily = new MacFontFamily(); fontFamily->load(*fond); Common::Array<Graphics::MacFontFamily::AsscEntry> *assoc = fontFamily->getAssocTable(); for (uint i = 0; i < assoc->size(); i++) { debug("size: %d style: %d id: %d", (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle, (*assoc)[i]._fontID); Common::SeekableReadStream *fontstream; MacFont *macfont; Graphics::MacFONTFont *font; fontstream = fontFile->getResource(MKTAG('N', 'F', 'N', 'T'), (*assoc)[i]._fontID); if (!fontstream) fontstream = fontFile->getResource(MKTAG('F', 'O', 'N', 'T'), (*assoc)[i]._fontID); if (!fontstream) { warning("Unknown FontId: %d", (*assoc)[i]._fontID); continue; } font = new Graphics::MacFONTFont; font->loadFont(*fontstream, fontFamily, (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle); delete fontstream; Common::String fontName = Common::String::format("%s-%d-%d", familyName.c_str(), (*assoc)[i]._fontStyle, (*assoc)[i]._fontSize); macfont = new MacFont(_fontNames.getVal(familyName, kMacFontNonStandard), (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle); FontMan.assignFontToName(fontName, font); macfont->setFont(font); _fontRegistry.setVal(fontName, macfont); debug(2, " %s", fontName.c_str()); } delete fond; } } delete fontFile; } _builtInFonts = false; delete dat; }
Common::SeekableReadStream *openDiskFile(const Common::String &filename) { uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; Common::String fixedFilename = filename; // Absolute path: TODO: Add specific fallbacks here. if (filename.contains(':')) { if (filename.hasPrefix("c:\\windows\\fonts\\")) { // East Side Story refers to "c:\windows\fonts\framd.ttf" fixedFilename = filename.c_str() + 17; } else { error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); } } // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, fixedFilename); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { if ((*it)->getName() == filename) { file = (*it)->createReadStream(); break; } } // File wasn't found in SearchMan, try to parse the path as a relative path. if (!file) { Common::FSNode searchNode = getNodeForRelativePath(filename); if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { file = searchNode.createReadStream(); } } if (file) { uint32 magic1, magic2; magic1 = file->readUint32LE(); magic2 = file->readUint32LE(); bool compressed = false; if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) { compressed = true; } if (compressed) { uint32 dataOffset, compSize, uncompSize; dataOffset = file->readUint32LE(); compSize = file->readUint32LE(); uncompSize = file->readUint32LE(); byte *compBuffer = new byte[compSize]; if (!compBuffer) { error("Error allocating memory for compressed file '%s'", filename.c_str()); delete file; return NULL; } byte *data = new byte[uncompSize]; if (!data) { error("Error allocating buffer for file '%s'", filename.c_str()); delete[] compBuffer; delete file; return NULL; } file->seek(dataOffset + prefixSize, SEEK_SET); file->read(compBuffer, compSize); if (Common::uncompress(data, (unsigned long *)&uncompSize, compBuffer, compSize) != true) { error("Error uncompressing file '%s'", filename.c_str()); delete[] compBuffer; delete file; return NULL; } delete[] compBuffer; delete file; return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); } else { file->seek(0, SEEK_SET); return file; } return file; } return NULL; }