bool TheWitcherEngineProbe::probe(const Common::UString &directory, const Common::FileList &rootFiles) const { // There should be a system directory Common::UString systemDir = Common::FilePath::findSubDirectory(directory, "system", true); if (systemDir.empty()) return false; // The system directory has to be readable Common::FileList systemFiles; if (!systemFiles.addDirectory(systemDir)) return false; // If either witcher.ini or witcher.exe exists, this should be a valid path return systemFiles.contains(".*/witcher.(exe|ini)", true); }
void NWNEngine::getCharacters(std::vector<Common::UString> &characters, bool local) { characters.clear(); Common::UString pcDir = ConfigMan.getString(local ? "NWN_localPCDir" : "NWN_serverPCDir"); if (pcDir.empty()) return; Common::FileList chars; chars.addDirectory(pcDir); for (Common::FileList::const_iterator c = chars.begin(); c != chars.end(); ++c) { if (!Common::FilePath::getExtension(*c).equalsIgnoreCase(".bic")) continue; characters.push_back(Common::FilePath::getStem(*c)); } }
void NWNEngine::getModules(std::vector<Common::UString> &modules) { modules.clear(); Common::UString moduleDir = ConfigMan.getString("NWN_extraModuleDir"); if (moduleDir.empty()) return; Common::FileList mods; mods.addDirectory(moduleDir); for (Common::FileList::const_iterator m = mods.begin(); m != mods.end(); ++m) { if (!Common::FilePath::getExtension(*m).equalsIgnoreCase(".mod")) continue; modules.push_back(Common::FilePath::getStem(*m)); } std::sort(modules.begin(), modules.end(), Common::UString::iless()); }
void ResourceManager::addArchiveDir(ArchiveType archive, const Common::UString &dir) { if (archive == kArchiveNDS || archive == kArchiveHERF) return; assert((archive >= 0) && (archive < kArchiveMAX)); Common::UString directory = Common::FilePath::findSubDirectory(_baseDir, dir, true); if (directory.empty()) throw Common::Exception("No such directory \"%s\"", dir.c_str()); Common::FileList dirFiles; if (!dirFiles.addDirectory(directory)) throw Common::Exception("Can't read directory \"%s\"", directory.c_str()); dirFiles.getSubList(kArchiveGlob[archive], _archiveFiles[archive], true); // If we're adding an ERF directory and .rim files are actually ERFs, add those too if ((archive == kArchiveERF) && _rimsAreERFs) dirFiles.getSubList(kArchiveGlob[kArchiveRIM], _archiveFiles[archive], true); _archiveDirs[archive].push_back(directory); }
void Campaign::findCampaigns() { Common::UString moduleDir = ConfigMan.getString("WITCHER_moduleDir"); if (moduleDir.empty()) return; Common::FileList modules; if (!modules.addDirectory(moduleDir, -1)) return; Common::FileList mmdFiles; if (!modules.getSubListGlob(".*\\.mmd", true, mmdFiles)) return; for (Common::FileList::const_iterator c = mmdFiles.begin(); c != mmdFiles.end(); ++c) { CampaignDescription desc; desc.directory = Common::FilePath::relativize(moduleDir, Common::FilePath::getDirectory(*c)); if (!readCampaign(*c, desc)) continue; _campaigns.push_back(desc); } }
void Game::getModules(std::vector<Common::UString> &modules) { modules.clear(); Common::UString moduleDir = ConfigMan.getString("KOTOR_moduleDir"); if (moduleDir.empty()) return; Common::FileList mods; mods.addDirectory(moduleDir); for (Common::FileList::const_iterator m = mods.begin(); m != mods.end(); ++m) { Common::UString file = m->toLower(); if (!file.endsWith("_s.rim")) continue; file = Common::FilePath::getStem(file); file.truncate(file.size() - Common::UString("_s").size()); modules.push_back(file); } std::sort(modules.begin(), modules.end(), Common::UString::iless()); }
bool GameInstanceEngine::probe() { if (Common::FilePath::isDirectory(_target)) { // Try to probe from that directory Common::FileList rootFiles; if (!rootFiles.addDirectory(_target)) // Fatal: can't read the directory return false; return probe(rootFiles); } if (Common::FilePath::isRegularFile(_target)) { // Try to probe from that file Common::ReadFile file; if (file.open(_target)) return probe(file); } return false; }