本文整理汇总了C++中common::fslist::const_iterator类的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_iterator类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: detectGames
bool GlulxeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
const char *const EXTENSIONS[3] = { ".ulx", ".blb", ".gblorb" };
// Loop through the files of the folder
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
// Check for a recognised filename
if (file->isDirectory())
continue;
Common::String filename = file->getName();
bool hasExt = false;
for (int idx = 0; idx < 3 && !hasExt; ++idx)
hasExt = filename.hasSuffixIgnoreCase(EXTENSIONS[idx]);
if (!hasExt)
continue;
// Open up the file and calculate the md5
Common::File gameFile;
if (!gameFile.open(*file))
continue;
Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
size_t filesize = gameFile.size();
gameFile.close();
// Check for known games
const GlulxeGameDescription *p = GLULXE_GAMES;
while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
++p;
DetectedGame gd;
if (!p->_gameId) {
if (filename.hasSuffixIgnoreCase(".blb"))
continue;
if (gDebugLevel > 0) {
// Print an entry suitable for putting into the detection_tables.h, using the
// name of the parent folder the game is in as the presumed game Id
Common::String folderName = file->getParent().getName();
if (folderName.hasSuffix("\\"))
folderName.deleteLastChar();
Common::String fname = filename;
const char *dot = strchr(fname.c_str(), '.');
if (dot)
fname = Common::String(fname.c_str(), dot);
debug("ENTRY0(\"%s\", \"%s\", %u),", fname.c_str(), md5.c_str(), (uint)filesize);
}
const PlainGameDescriptor &desc = GLULXE_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
} else {
PlainGameDescriptor gameDesc = findGame(p->_gameId);
gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra);
gd.setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
}
gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}
return !gameList.empty();
}
开发者ID:Templier,项目名称:scummvm,代码行数:60,代码来源:detection.cpp
示例2: findGames
static int findGames(Game *games, int max)
{
Dir *dirs = new Dir[MAX_DIR];
int curr_game = 0, curr_dir = 0, num_dirs = 1;
dirs[0].node = Common::FSNode("");
while (curr_game < max && curr_dir < num_dirs) {
strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 252);
dirs[curr_dir].name[251] = '\0';
dirs[curr_dir].deficon[0] = '\0';
Common::FSList files, fslist;
dirs[curr_dir++].node.getChildren(fslist, Common::FSNode::kListAll);
for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end();
++entry) {
if (entry->isDirectory()) {
if (num_dirs < MAX_DIR && strcasecmp(entry->getDisplayName().c_str(),
"install")) {
dirs[num_dirs].node = *entry;
num_dirs++;
}
} else
if (isIcon(*entry))
strcpy(dirs[curr_dir-1].deficon, entry->getDisplayName().c_str());
else
files.push_back(*entry);
}
GameList candidates = EngineMan.detectGames(files);
for (GameList::const_iterator ge = candidates.begin();
ge != candidates.end(); ++ge)
if (curr_game < max) {
strcpy(games[curr_game].filename_base, ge->gameid().c_str());
strcpy(games[curr_game].dir, dirs[curr_dir-1].name);
games[curr_game].language = ge->language();
games[curr_game].platform = ge->platform();
if (uniqueGame(games[curr_game].filename_base,
games[curr_game].dir,
games[curr_game].language,
games[curr_game].platform, games, curr_game)) {
strcpy(games[curr_game].text, ge->description().c_str());
#if 0
printf("Registered game <%s> (l:%d p:%d) in <%s> <%s> because of <%s> <*>\n",
games[curr_game].text,
(int)games[curr_game].language,
(int)games[curr_game].platform,
games[curr_game].dir, games[curr_game].filename_base,
dirs[curr_dir-1].name);
#endif
curr_game++;
}
}
}
for (int i=0; i<curr_game; i++)
if (!loadIcon(games[i], dirs, num_dirs))
makeDefIcon(games[i].icon);
delete[] dirs;
return curr_game;
}
开发者ID:havlenapetr,项目名称:Scummvm,代码行数:60,代码来源:selector.cpp
示例3: registerPackages
bool BaseFileManager::registerPackages(const Common::FSList &fslist) {
for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); ++it) {
debugC(kWintermuteDebugFileAccess, "Adding %s", it->getName().c_str());
if (it->getName().contains(".dcp")) {
if (registerPackage(*it)) {
addPath(PATH_PACKAGE, *it);
}
}
}
return true;
}
开发者ID:dergunov,项目名称:scummvm,代码行数:11,代码来源:base_file_manager.cpp
示例4: isFullGame
bool isFullGame(const Common::FSList &fslist) {
Common::FSList::const_iterator file;
// We distinguish between the two versions by the presense of paris.clu
for (file = fslist.begin(); file != fslist.end(); ++file) {
if (!file->isDirectory()) {
if (file->getName().equalsIgnoreCase("paris.clu"))
return true;
}
}
return false;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:13,代码来源:sword2.cpp
示例5: detectGames
bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
// Loop through the files of the folder
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
// Check for a recognised filename
Common::String filename = file->getName();
if (file->isDirectory() || !(filename.hasSuffixIgnoreCase(".gam")
|| filename.hasSuffixIgnoreCase(".blorb")))
continue;
// Open up the file and calculate the md5
Common::File gameFile;
if (!gameFile.open(*file))
continue;
Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
size_t filesize = gameFile.size();
gameFile.close();
// Check for known games
const TADSGameDescription *p = TADS_GAMES;
while (p->_gameId && p->_md5 && (md5 != p->_md5 || filesize != p->_filesize))
++p;
DetectedGame gd;
if (!p->_gameId) {
if (!filename.hasSuffixIgnoreCase(".gam"))
continue;
if (gDebugLevel > 0) {
// Print an entry suitable for putting into the detection_tables.h, using the
Common::String fname = filename;
const char *dot = strchr(fname.c_str(), '.');
if (dot)
fname = Common::String(fname.c_str(), dot);
debug("ENTRY0(\"%s\", \"%s\", %u),", fname.c_str(), md5.c_str(), (uint)filesize);
}
const TADSDescriptor &desc = TADS_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
}
else {
PlainGameDescriptor gameDesc = findGame(p->_gameId);
gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra);
}
gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}
return !gameList.empty();
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:50,代码来源:detection.cpp
示例6: detectGames
GameList SkyMetaEngine::detectGames(const Common::FSList &fslist) const {
GameList detectedGames;
bool hasSkyDsk = false;
bool hasSkyDnr = false;
int dinnerTableEntries = -1;
int dataDiskSize = -1;
// Iterate over all files in the given directory
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (!file->isDirectory()) {
const char *fileName = file->getName().c_str();
if (0 == scumm_stricmp("sky.dsk", fileName)) {
Common::File dataDisk;
if (dataDisk.open(*file)) {
hasSkyDsk = true;
dataDiskSize = dataDisk.size();
}
}
if (0 == scumm_stricmp("sky.dnr", fileName)) {
Common::File dinner;
if (dinner.open(*file)) {
hasSkyDnr = true;
dinnerTableEntries = dinner.readUint32LE();
}
}
}
}
if (hasSkyDsk && hasSkyDnr) {
// Match found, add to list of candidates, then abort inner loop.
// The game detector uses US English by default. We want British
// English to match the recorded voices better.
GameDescriptor dg("sky", skySetting.gameid, skySetting.description, Common::UNK_LANG, Common::kPlatformUnknown);
const SkyVersion *sv = skyVersions;
while (sv->dinnerTableEntries) {
if (dinnerTableEntries == sv->dinnerTableEntries &&
(sv->dataDiskSize == dataDiskSize || sv->dataDiskSize == -1)) {
dg.updateDesc(Common::String::format("v0.0%d %s", sv->version, sv->extraDesc).c_str());
dg.setGUIOptions(sv->guioptions);
break;
}
++sv;
}
detectedGames.push_back(dg);
}
return detectedGames;
}
开发者ID:project-cabal,项目名称:cabal,代码行数:50,代码来源:detection.cpp
示例7: assureCached
void DefaultSaveFileManager::assureCached(const Common::String &savePathName) {
// Check that path exists and is usable.
checkPath(Common::FSNode(savePathName));
#ifdef USE_LIBCURL
Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing
if (!files.empty()) updateSavefilesList(files); //makes this cache invalid
else _lockedFiles = files;
#endif
if (_cachedDirectory == savePathName) {
return;
}
_saveFileCache.clear();
_cachedDirectory.clear();
if (getError().getCode() != Common::kNoError) {
warning("DefaultSaveFileManager::assureCached: Can not cache path '%s': '%s'", savePathName.c_str(), getErrorDesc().c_str());
return;
}
// FSNode can cache its members, thus create it after checkPath to reflect
// actual file system state.
const Common::FSNode savePath(savePathName);
Common::FSList children;
if (!savePath.getChildren(children, Common::FSNode::kListFilesOnly)) {
return;
}
// Build the savefile name cache.
for (Common::FSList::const_iterator file = children.begin(), end = children.end(); file != end; ++file) {
if (_saveFileCache.contains(file->getName())) {
warning("DefaultSaveFileManager::assureCached: Name clash when building cache, ignoring file '%s'", file->getName().c_str());
} else {
_saveFileCache[file->getName()] = *file;
}
}
// Only now store that we cached 'savePathName' to indicate we successfully
// cached the directory.
_cachedDirectory = savePathName;
}
开发者ID:peterkohaut,项目名称:scummvm,代码行数:44,代码来源:default-saves.cpp
示例8: composeFileHashMap
static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth, const char * const *directoryGlobs) {
if (depth <= 0)
return;
if (fslist.empty())
return;
// First we compose a hashmap of all files in fslist.
// Includes nifty stuff like removing trailing dots and ignoring case.
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory()) {
Common::FSList files;
if (!directoryGlobs)
continue;
bool matched = false;
for (const char * const *glob = directoryGlobs; *glob; glob++)
if (file->getName().matchString(*glob, true)) {
matched = true;
break;
}
if (!matched)
continue;
if (!file->getChildren(files, Common::FSNode::kListAll))
continue;
composeFileHashMap(files, allFiles, depth - 1, directoryGlobs);
}
Common::String tstr = file->getName();
// Strip any trailing dot
if (tstr.lastChar() == '.')
tstr.deleteLastChar();
allFiles[tstr] = *file; // Record the presence of this file
}
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:41,代码来源:advancedDetector.cpp
示例9: Sword1CheckDirectory
void Sword1CheckDirectory(const Common::FSList &fslist, bool *filesFound, bool recursion = false) {
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (!file->isDirectory()) {
// The required game data files can be located in the game directory, or in
// a subdirectory called "clusters". In the latter case, we don't want to
// detect the game in that subdirectory, as this will detect the game twice
// when mass add is searching inside a directory. In this case, the first
// result (the game directory) will be correct, but the second result (the
// clusters subdirectory) will be wrong, as the optional speech, music and
// video data files will be ignored. Note that this fix will skip the game
// data files if the user has placed them inside a "clusters" subdirectory,
// or if he/she points ScummVM directly to the "clusters" directory of the
// game CD. Fixes bug #3049346.
Common::String directory = file->getParent().getName();
directory.toLowercase();
if (directory.hasPrefix("clusters") && directory.size() <= 9 && !recursion)
continue;
const char *fileName = file->getName().c_str();
for (int cnt = 0; cnt < NUM_FILES_TO_CHECK; cnt++)
if (scumm_stricmp(fileName, g_filesToCheck[cnt]) == 0)
filesFound[cnt] = true;
} else {
for (int cnt = 0; cnt < ARRAYSIZE(g_dirNames); cnt++)
if (scumm_stricmp(file->getName().c_str(), g_dirNames[cnt]) == 0) {
Common::FSList fslist2;
if (file->getChildren(fslist2, Common::FSNode::kListFilesOnly))
Sword1CheckDirectory(fslist2, filesFound, true);
}
}
}
}
开发者ID:project-cabal,项目名称:cabal,代码行数:32,代码来源:detection.cpp
示例10: composeFileHashMap
void AdvancedMetaEngine::composeFileHashMap(FileMap &allFiles, const Common::FSList &fslist, int depth, const Common::String &parentName) const {
if (depth <= 0)
return;
if (fslist.empty())
return;
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
Common::String tstr = (_matchFullPaths && !parentName.empty() ? parentName + "/" : "") + file->getName();
if (file->isDirectory()) {
Common::FSList files;
if (!_directoryGlobs)
continue;
bool matched = false;
for (const char * const *glob = _directoryGlobs; *glob; glob++)
if (file->getName().matchString(*glob, true)) {
matched = true;
break;
}
if (!matched)
continue;
if (!file->getChildren(files, Common::FSNode::kListAll))
continue;
composeFileHashMap(allFiles, files, depth - 1, tstr);
}
// Strip any trailing dot
if (tstr.lastChar() == '.')
tstr.deleteLastChar();
allFiles[tstr] = *file; // Record the presence of this file
}
}
开发者ID:Botje,项目名称:residualvm,代码行数:39,代码来源:advancedDetector.cpp
示例11: directory
Common::HashMap<Common::String, Score *> DirectorEngine::loadMMMNames(Common::String folder) {
Common::FSNode directory(folder);
Common::FSList movies;
Common::HashMap<Common::String, Score *> nameMap;
directory.getChildren(movies, Common::FSNode::kListFilesOnly);
if (!movies.empty()) {
for (Common::FSList::const_iterator i = movies.begin(); i != movies.end(); ++i) {
if (i->getName() == _sharedMMM) {
loadSharedCastsFrom(i->getPath());
continue;
}
RIFFArchive *arc = new RIFFArchive();
arc->openFile(i->getPath());
Score *sc = new Score(this);
nameMap[sc->getMacName()] = sc;
}
}
return nameMap;
}
开发者ID:iskrich,项目名称:director,代码行数:23,代码来源:director.cpp
示例12: recGames
GameList Sword2MetaEngine::detectGames(const Common::FSList &fslist) const {
GameList detectedGames;
const Sword2::GameSettings *g;
Common::FSList::const_iterator file;
// TODO: It would be nice if we had code here which distinguishes
// between the 'sword2' and 'sword2demo' targets. The current code
// can't do that since they use the same detectname.
for (g = Sword2::sword2_settings; g->gameid; ++g) {
// Iterate over all files in the given directory
for (file = fslist.begin(); file != fslist.end(); ++file) {
if (!file->isDirectory()) {
const char *fileName = file->getName().c_str();
if (0 == scumm_stricmp(g->detectname, fileName)) {
// Match found, add to list of candidates, then abort inner loop.
detectedGames.push_back(GameDescriptor(g->gameid, g->description, Common::UNK_LANG, Common::kPlatformUnknown, Common::GUIO_NOMIDI));
break;
}
}
}
}
if (detectedGames.empty()) {
// Nothing found -- try to recurse into the 'clusters' subdirectory,
// present e.g. if the user copied the data straight from CD.
for (file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory()) {
const char *fileName = file->getName().c_str();
if (0 == scumm_stricmp("clusters", fileName)) {
Common::FSList recList;
if (file->getChildren(recList, Common::FSNode::kListAll)) {
GameList recGames(detectGames(recList));
if (!recGames.empty()) {
detectedGames.push_back(recGames);
break;
}
}
}
}
}
}
return detectedGames;
}
开发者ID:jweinberg,项目名称:scummvm,代码行数:49,代码来源:sword2.cpp
示例13: dir
bool Sword25Engine::loadPackages() {
PackageManager *packageManagerPtr = Kernel::getInstance()->getPackage();
assert(packageManagerPtr);
// Load the main package
if (!packageManagerPtr->loadPackage("data.b25c", "/"))
return false;
// Get the contents of the main program directory and sort them alphabetically
Common::FSNode dir(ConfMan.get("path"));
Common::FSList files;
if (!dir.isDirectory() || !dir.getChildren(files, Common::FSNode::kListAll)) {
warning("Game data path does not exist or is not a directory");
return false;
}
Common::sort(files.begin(), files.end());
// Identify all patch packages
// The filename of patch packages must have the form patch??.b25c, with the question marks
// are placeholders for numbers.
// Since the filenames have been sorted, patches are mounted with low numbers first, through
// to ones with high numbers. This is important, because newly mount packages overwrite
// existing files in the virtual file system, if they include files with the same name.
for (Common::FSList::const_iterator it = files.begin(); it != files.end(); ++it) {
if (it->getName().matchString("patch???.b25c", true))
if (!packageManagerPtr->loadPackage(it->getName(), "/"))
return false;
}
// Identify and mount all language packages
// The filename of the packages have the form lang_*.b25c (eg. lang_de.b25c)
for (Common::FSList::const_iterator it = files.begin(); it != files.end(); ++it) {
if (it->getName().matchString("lang_*.b25c", true))
if (!packageManagerPtr->loadPackage(it->getName(), "/"))
return false;
}
return true;
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:40,代码来源:sword25.cpp
示例14: directory
Common::HashMap<Common::String, Score *> *DirectorEngine::scanMovies(const Common::String &folder) {
Common::FSNode directory(folder);
Common::FSList movies;
const char *sharedMMMname;
if (getPlatform() == Common::kPlatformWindows)
sharedMMMname = "SHARDCST.MMM";
else
sharedMMMname = "Shared Cast*";
Common::HashMap<Common::String, Score *> *nameMap = new Common::HashMap<Common::String, Score *>();
if (!directory.getChildren(movies, Common::FSNode::kListFilesOnly))
return nameMap;
if (!movies.empty()) {
for (Common::FSList::const_iterator i = movies.begin(); i != movies.end(); ++i) {
debugC(2, kDebugLoading, "File: %s", i->getName().c_str());
if (Common::matchString(i->getName().c_str(), sharedMMMname, true)) {
_sharedCastFile = i->getName();
continue;
}
Archive *arc = createArchive();
warning("name: %s", i->getName().c_str());
arc->openFile(i->getName());
Score *sc = new Score(this, arc);
nameMap->setVal(sc->getMacName(), sc);
debugC(2, kDebugLoading, "Movie name: \"%s\"", sc->getMacName().c_str());
}
}
return nameMap;
}
开发者ID:86400,项目名称:scummvm,代码行数:37,代码来源:director.cpp
示例15: detectGames
bool FrotzMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
const char *const EXTENSIONS[] = { ".z1", ".z2", ".z3", ".z4", ".z5", ".z6", ".z7", ".z8",
".dat", ".zip", nullptr };
// Loop through the files of the folder
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
// Check for a recognised filename
if (file->isDirectory())
continue;
Common::String filename = file->getName();
bool hasExt = Blorb::hasBlorbExt(filename), isBlorb = false;
for (const char *const *ext = &EXTENSIONS[0]; *ext && !hasExt; ++ext)
hasExt = filename.hasSuffixIgnoreCase(*ext);
if (!hasExt)
continue;
// Open up the file and calculate the md5, and get the serial
Common::File gameFile;
if (!gameFile.open(*file))
continue;
Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
size_t filesize = gameFile.size();
char serial[9] = "";
bool emptyBlorb = false;
gameFile.seek(0);
isBlorb = Blorb::isBlorb(gameFile, ID_ZCOD);
if (!isBlorb) {
if (Blorb::hasBlorbExt(filename)) {
gameFile.close();
continue;
}
gameFile.seek(18);
strcpy(&serial[0], "\"");
gameFile.read(&serial[1], 6);
strcpy(&serial[7], "\"");
} else {
Blorb b(*file, INTERPRETER_FROTZ);
Common::SeekableReadStream *f = b.createReadStreamForMember("game");
emptyBlorb = f == nullptr;
if (!emptyBlorb) {
f->seek(18);
strcpy(&serial[0], "\"");
f->read(&serial[1], 6);
strcpy(&serial[7], "\"");
delete f;
}
}
gameFile.close();
// Check for known games. Note that there has been some variation in exact filesizes
// for Infocom games due to padding at the end of files. So we match on md5s for the
// first 5Kb, and only worry about filesize for more recent Blorb based Zcode games
const FrotzGameDescription *p = FROTZ_GAMES;
while (p->_gameId && p->_md5 && (md5 != p->_md5 ||
(filesize != p->_filesize && isBlorb)))
++p;
DetectedGame gd;
if (!p->_gameId) {
// Generic .dat/.zip files don't get reported as matches unless they have a known md5
if (filename.hasSuffixIgnoreCase(".dat") || filename.hasSuffixIgnoreCase(".zip") || emptyBlorb)
continue;
if (gDebugLevel > 0) {
// Print an entry suitable for putting into the detection_tables.h, using the
// name of the parent folder the game is in as the presumed game Id
Common::String folderName = file->getParent().getName();
if (folderName.hasSuffix("\\"))
folderName.deleteLastChar();
Common::String fname = filename;
const char *dot = strchr(fname.c_str(), '.');
if (dot)
fname = Common::String(fname.c_str(), dot);
debug("ENTRY0(\"%s\", %s, \"%s\", %u),",
fname.c_str(), strlen(serial) ? serial : "nullptr", md5.c_str(), (uint)filesize);
}
const PlainGameDescriptor &desc = ZCODE_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
} else {
GameDescriptor gameDesc = findGame(p->_gameId);
gd = DetectedGame(p->_gameId, gameDesc._description, p->_language, Common::kPlatformUnknown, p->_extra);
gd.setGUIOptions(p->_guiOptions);
}
gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}
return !gameList.empty();
}
开发者ID:fingolfin,项目名称:scummvm,代码行数:93,代码来源:detection.cpp
示例16: detectGamesImpl
GameList detectGamesImpl(const Common::FSList &fslist, bool recursion = false) {
GameList detectedGames;
const Sword2::GameSettings *g;
Common::FSList::const_iterator file;
bool isFullVersion = isFullGame(fslist);
for (g = Sword2::sword2_settings; g->gameid; ++g) {
// Iterate over all files in the given directory
for (file = fslist.begin(); file != fslist.end(); ++file) {
if (!file->isDirectory()) {
// The required game data files can be located in the game directory, or in
// a subdirectory called "clusters". In the latter case, we don't want to
// detect the game in that subdirectory, as this will detect the game twice
// when mass add is searching inside a directory. In this case, the first
// result (the game directory) will be correct, but the second result (the
// clusters subdirectory) will be wrong, as the optional speech, music and
// video data files will be ignored. Note that this fix will skip the game
// data files if the user has placed them inside a "clusters" subdirectory,
// or if he/she points ScummVM directly to the "clusters" directory of the
// game CD. Fixes bug #3049336.
Common::String directory = file->getParent().getName();
directory.toLowercase();
if (directory.hasPrefix("clusters") && directory.size() <= 9 && !recursion)
continue;
if (file->getName().equalsIgnoreCase(g->detectname)) {
// Make sure that the sword2 demo is not mixed up with the
// full version, since they use the same filename for detection
if ((g->features == Sword2::GF_DEMO && isFullVersion) ||
(g->features == 0 && !isFullVersion))
continue;
// Match found, add to list of candidates, then abort inner loop.
detectedGames.push_back(GameDescriptor(g->gameid, g->description, Common::UNK_LANG, Common::kPlatformUnknown, GUIO2(GUIO_NOMIDI, GUIO_NOASPECT)));
break;
}
}
}
}
if (detectedGames.empty()) {
// Nothing found -- try to recurse into the 'clusters' subdirectory,
// present e.g. if the user copied the data straight from CD.
for (file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory()) {
if (file->getName().equalsIgnoreCase("clusters")) {
Common::FSList recList;
if (file->getChildren(recList, Common::FSNode::kListAll)) {
GameList recGames(detectGamesImpl(recList, true));
if (!recGames.empty()) {
detectedGames.push_back(recGames);
break;
}
}
}
}
}
}
return detectedGames;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:63,代码来源:sword2.cpp
示例17: fallbackDetect
ADDetectedGame DirectorMetaEngine::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
// TODO: Handle Mac fallback
// reset fallback description
Director::DirectorGameDescription *desc = &s_fallbackDesc;
desc->desc.gameId = "director";
desc->desc.extra = "";
desc->desc.language = Common::UNK_LANG;
desc->desc.flags = ADGF_NO_FLAGS;
desc->desc.platform = Common::kPlatformWindows;
desc->desc.guiOptions = GUIO0();
desc->desc.filesDescriptions[0].fileName = 0;
desc->version = 0;
desc->gameID = Director::GID_GENERIC;
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory())
continue;
Common::String fileName = file->getName();
fileName.toLowercase();
if (!fileName.hasSuffix(".exe"))
continue;
Common::File f;
if (!f.open(*file))
continue;
f.seek(-4, SEEK_END);
uint32 offset = f.readUint32LE();
if (f.eos() || offset == 0 || offset >= (uint32)(f.size() - 4))
continue;
f.seek(offset);
uint32 tag = f.readUint32LE();
switch (tag) {
case MKTAG('3', '9', 'J', 'P'):
desc->version = 4;
break;
case MKTAG('P', 'J', '9', '5'):
desc->version = 5;
break;
case MKTAG('P', 'J', '0', '0'):
desc->version = 7;
break;
default:
// Prior to version 4, there was no tag here. So we'll use a bit of a
// heuristic to detect. The first field is the entry count, of which
// there should only be one.
if ((tag & 0xFFFF) != 1)
continue;
f.skip(3);
uint32 mmmSize = f.readUint32LE();
if (f.eos() || mmmSize == 0)
continue;
byte fileNameSize = f.readByte();
if (f.eos())
continue;
f.skip(fileNameSize);
byte directoryNameSize = f.readByte();
if (f.eos())
continue;
f.skip(directoryNameSize);
if (f.pos() != f.size() - 4)
continue;
// Assume v3 at this point (for now at least)
desc->version = 3;
}
strncpy(s_fallbackFileNameBuffer, fileName.c_str(), 50);
s_fallbackFileNameBuffer[50] = '\0';
desc->desc.filesDescriptions[0].fileName = s_fallbackFileNameBuffer;
warning("Director fallback detection D%d", desc->version);
return ADDetectedGame(&desc->desc);
}
return ADDetectedGame();
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:94,代码来源:detection.cpp
注:本文中的common::fslist::const_iterator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论