本文整理汇总了C++中common::FSList类的典型用法代码示例。如果您正苦于以下问题:C++ FSList类的具体用法?C++ FSList怎么用?C++ FSList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FSList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: detectGames
GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
ADGameDescList matches;
GameList detectedGames;
FileMap allFiles;
if (fslist.empty())
return detectedGames;
// Compose a hashmap of all files in fslist.
composeFileHashMap(allFiles, fslist, (_maxScanDepth == 0 ? 1 : _maxScanDepth));
// Run the detector on this
matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, "");
if (matches.empty()) {
// Use fallback detector if there were no matches by other means
const ADGameDescription *fallbackDesc = fallbackDetect(allFiles, fslist);
if (fallbackDesc != 0) {
GameDescriptor desc(toGameDescriptor(*fallbackDesc, _gameIds));
updateGameDescriptor(desc, fallbackDesc);
detectedGames.push_back(desc);
}
} else {
// Otherwise use the found matches
cleanupPirated(matches);
for (uint i = 0; i < matches.size(); i++) {
GameDescriptor desc(toGameDescriptor(*matches[i], _gameIds));
updateGameDescriptor(desc, matches[i]);
detectedGames.push_back(desc);
}
}
return detectedGames;
}
示例3: 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);
}
}
}
}
示例4: 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;
}
示例5: 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;
}
示例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;
}
示例7: 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();
}
示例8: 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;
}
示例9: 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;
}
示例10: automaticScanDirectory
void CELauncherDialog::automaticScanDirectory(const Common::FSNode &node) {
// First check if we have a recognized game in the current directory
Common::FSList files;
node.getChildren(files, Common::FSNode::kListFilesOnly);
// detect
GameList candidates(EngineMan.detectGames(files));
// insert
if (candidates.size() >= 1) {
GameDescriptor result = candidates[0];
result["path"] = node.getPath();
addGameToConf(result);
}
// Then recurse on the subdirectories
Common::FSList dirs;
node.getChildren(dirs, Common::FSNode::kListDirectoriesOnly);
for (Common::FSList::const_iterator currentDir = dirs.begin(); currentDir != dirs.end(); ++currentDir)
automaticScanDirectory(*currentDir);
}
示例11: registerPackages
bool BaseFileManager::registerPackages() {
debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Scanning packages");
// Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail
// and that has to be like that to support the detection-scheme.
Common::FSList files;
for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); ++it) {
debugC(kWintermuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str());
if (!(*it).getChildren(files, Common::FSNode::kListFilesOnly)) {
warning("getChildren() failed for path: %s", (*it).getDisplayName().c_str());
}
for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
if (!fileIt->getName().hasSuffix(".dcp")) {
continue;
}
// Avoid registering all the language files
// TODO: Select based on the gameDesc.
if (_language != Common::UNK_LANG && fileIt->getParent().getName() == "language") {
Common::String parentName = fileIt->getParent().getName();
Common::String dcpName = fileIt->getName();
if (_language == Common::EN_ANY && fileIt->getName() != "english.dcp") {
continue;
} else if (_language == Common::CZ_CZE && fileIt->getName() != "czech.dcp") {
continue;
} else if (_language == Common::IT_ITA && fileIt->getName() != "italian.dcp") {
continue;
} else if (_language == Common::PL_POL && fileIt->getName() != "polish.dcp") {
continue;
} else if (_language == Common::RU_RUS && fileIt->getName() != "russian.dcp") {
continue;
}
}
debugC(kWintermuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str());
registerPackage((*fileIt));
}
}
// debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size());
return STATUS_OK;
}
示例12: 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
}
}
示例13: 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
}
}
示例14: 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;
}
示例15: listUsableThemes
void ThemeEngine::listUsableThemes(const Common::FSNode &node, Common::List<ThemeDescriptor> &list, int depth) {
if (!node.exists() || !node.isReadable() || !node.isDirectory())
return;
ThemeDescriptor td;
// Check whether we point to a valid theme directory.
if (themeConfigUsable(node, td.name)) {
td.filename = node.getPath();
td.id = node.getName();
list.push_back(td);
// A theme directory should never contain any other themes
// thus we just return to the caller here.
return;
}
Common::FSList fileList;
// Check all files. We need this to find all themes inside ZIP archives.
if (!node.getChildren(fileList, Common::FSNode::kListFilesOnly))
return;
for (Common::FSList::iterator i = fileList.begin(); i != fileList.end(); ++i) {
// We will only process zip files for now
if (!i->getPath().matchString("*.zip", true))
continue;
td.name.clear();
if (themeConfigUsable(*i, td.name)) {
td.filename = i->getPath();
td.id = i->getName();
// 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();
// Check if we exceeded the given recursion depth
if (depth - 1 == -1)
return;
// As next step we will search all subdirectories
if (!node.getChildren(fileList, Common::FSNode::kListDirectoriesOnly))
return;
for (Common::FSList::iterator i = fileList.begin(); i != fileList.end(); ++i)
listUsableThemes(*i, list, depth == -1 ? - 1 : depth - 1);
}