本文整理汇总了C++中common::FSNode::getPath方法的典型用法代码示例。如果您正苦于以下问题:C++ FSNode::getPath方法的具体用法?C++ FSNode::getPath怎么用?C++ FSNode::getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::FSNode
的用法示例。
在下文中一共展示了FSNode::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkPath
void DefaultSaveFileManager::checkPath(const Common::FSNode &dir) {
clearError();
if (!dir.exists()) {
setError(Common::kPathDoesNotExist, "The savepath '"+dir.getPath()+"' does not exist");
} else if (!dir.isDirectory()) {
setError(Common::kPathNotDirectory, "The savepath '"+dir.getPath()+"' is not a directory");
}
}
示例2: cmd_saveOriginal
bool Debugger_EoB::cmd_saveOriginal(int argc, const char **argv) {
if (!_vm->_runFlag) {
DebugPrintf("This command doesn't work during intro or outro sequences,\nfrom the main menu or from the character generation.\n");
return true;
}
Common::String dir = ConfMan.get("savepath");
if (dir == "None")
dir.clear();
Common::FSNode nd(dir);
if (!nd.isDirectory())
return false;
if (_vm->game() == GI_EOB1) {
if (argc == 1) {
if (_vm->saveAsOriginalSaveFile()) {
Common::FSNode nf = nd.getChild(Common::String::format("EOBDATA.SAV"));
if (nf.isReadable())
DebugPrintf("Saved to file: %s\n\n", nf.getPath().c_str());
else
DebugPrintf("Failure.\n");
} else {
DebugPrintf("Failure.\n");
}
} else {
DebugPrintf("Syntax: save_original\n (Saves game in original file format to a file which can be used with the orginal game executable.)\n\n");
}
return true;
} else if (argc == 2) {
int slot = atoi(argv[1]);
if (slot < 0 || slot > 5) {
DebugPrintf("Slot must be between (including) 0 and 5.\n");
} else if (_vm->saveAsOriginalSaveFile(slot)) {
Common::FSNode nf = nd.getChild(Common::String::format("EOBDATA%d.SAV", slot));
if (nf.isReadable())
DebugPrintf("Saved to file: %s\n\n", nf.getPath().c_str());
else
DebugPrintf("Failure.\n");
} else {
DebugPrintf("Failure.\n");
}
return true;
}
DebugPrintf("Syntax: save_original <slot>\n (Saves game in original file format to a file which can be used with the orginal game executable.\n A save slot between 0 and 5 must be specified.)\n\n");
return true;
}
示例3: savePath
bool Ps2SaveFileManager::removeSavefile(const Common::String &filename) {
Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
Common::FSNode file;
if (!savePath.exists() || !savePath.isDirectory())
return false;
if (_getDev(savePath) == MC_DEV) {
// if (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0) {
char path[32], temp[32];
strcpy(temp, filename.c_str());
// mcSplit(temp, game, ext);
char *game = strdup(strtok(temp, "."));
char *ext = strdup(strtok(NULL, "*"));
sprintf(path, "mc0:ScummVM/%s", game); // per game path
mcCheck(path);
sprintf(path, "mc0:ScummVM/%s/%s.sav", game, ext);
file = Common::FSNode(path);
free(game);
free(ext);
} else {
file = savePath.getChild(filename);
}
if (!file.exists() || file.isDirectory())
return false;
fio.remove(file.getPath().c_str());
return true;
}
示例4: removeSavefile
bool TizenSaveFileManager::removeSavefile(const Common::String &filename) {
Common::String savePathName = getSavePath();
checkPath(Common::FSNode(savePathName));
if (getError().getCode() != Common::kNoError) {
return false;
}
// recreate FSNode since checkPath may have changed/created the directory
Common::FSNode savePath(savePathName);
Common::FSNode file = savePath.getChild(filename);
String unicodeFileName;
StringUtil::Utf8ToString(file.getPath().c_str(), unicodeFileName);
switch (Tizen::Io::File::Remove(unicodeFileName)) {
case E_SUCCESS:
return true;
case E_ILLEGAL_ACCESS:
setError(Common::kWritePermissionDenied, "Search or write permission denied: " +
file.getName());
break;
default:
setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() +
"' does not exist or path is invalid");
break;
}
return false;
}
示例5: reportUnknown
void AdvancedMetaEngine::reportUnknown(const Common::FSNode &path, const ADFilePropertiesMap &filesProps, const ADGameIdList &matchedGameIds) const {
Common::String report = Common::String::format(
_("The game in '%s' seems to be an unknown %s engine game "
"variant.\n\nPlease report the following data to the ResidualVM "
"team at %s along with the name of the game you tried to add and "
"its version, language, etc.:"),
path.getPath().c_str(), getName(), "https://github.com/residualvm/residualvm/issues");
if (matchedGameIds.size()) {
report += "\n\n";
report += _("Matched game IDs:");
report += " ";
for (ADGameIdList::const_iterator gameId = matchedGameIds.begin(); gameId != matchedGameIds.end(); ++gameId) {
if (gameId != matchedGameIds.begin()) {
report += ", ";
}
report += *gameId;
}
}
report += "\n\n";
report.wordWrap(80);
for (ADFilePropertiesMap::const_iterator file = filesProps.begin(); file != filesProps.end(); ++file)
report += Common::String::format(" {\"%s\", 0, \"%s\", %d},\n", file->_key.c_str(), file->_value.md5.c_str(), file->_value.size);
report += "\n";
g_system->logMessage(LogMessageType::kInfo, report.c_str());
}
示例6: removeSavefile
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
Common::String savePathName = getSavePath();
checkPath(Common::FSNode(savePathName));
if (getError().getCode() != Common::kNoError)
return false;
// recreate FSNode since checkPath may have changed/created the directory
Common::FSNode savePath(savePathName);
Common::FSNode file = savePath.getChild(filename);
// FIXME: remove does not exist on all systems. If your port fails to
// compile because of this, please let us know (scummvm-devel or Fingolfin).
// There is a nicely portable workaround, too: Make this method overloadable.
if (remove(file.getPath().c_str()) != 0) {
#ifndef _WIN32_WCE
if (errno == EACCES)
setError(Common::kWritePermissionDenied, "Search or write permission denied: "+file.getName());
if (errno == ENOENT)
setError(Common::kPathDoesNotExist, "removeSavefile: '"+file.getName()+"' does not exist or path is invalid");
#endif
return false;
} else {
return true;
}
}
示例7: listDirectory
bool FilesPageHandler::listDirectory(Common::String path, Common::String &content, const Common::String &itemTemplate) {
if (path == "" || path == "/") {
if (ConfMan.hasKey("rootpath", "cloud"))
addItem(content, itemTemplate, IT_DIRECTORY, "/root/", _("File system root"));
addItem(content, itemTemplate, IT_DIRECTORY, "/saves/", _("Saved games"));
return true;
}
if (HandlerUtils::hasForbiddenCombinations(path))
return false;
Common::String prefixToRemove = "", prefixToAdd = "";
if (!transformPath(path, prefixToRemove, prefixToAdd))
return false;
Common::FSNode node = Common::FSNode(path);
if (path == "/")
node = node.getParent(); // absolute root
if (!HandlerUtils::permittedPath(node.getPath()))
return false;
if (!node.isDirectory())
return false;
// list directory
Common::FSList _nodeContent;
if (!node.getChildren(_nodeContent, Common::FSNode::kListAll, false)) // do not show hidden files
_nodeContent.clear();
else
Common::sort(_nodeContent.begin(), _nodeContent.end());
// add parent directory link
{
Common::String filePath = path;
if (filePath.hasPrefix(prefixToRemove))
filePath.erase(0, prefixToRemove.size());
if (filePath == "" || filePath == "/" || filePath == "\\")
filePath = "/";
else
filePath = parentPath(prefixToAdd + filePath);
addItem(content, itemTemplate, IT_PARENT_DIRECTORY, filePath, _("Parent directory"));
}
// fill the content
for (Common::FSList::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
Common::String name = i->getDisplayName();
if (i->isDirectory())
name += "/";
Common::String filePath = i->getPath();
if (filePath.hasPrefix(prefixToRemove))
filePath.erase(0, prefixToRemove.size());
filePath = prefixToAdd + filePath;
addItem(content, itemTemplate, detectType(i->isDirectory(), name), filePath, name);
}
return true;
}
示例8: 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);
}
示例9: getSavegameDirectory
Common::String PersistenceService::getSavegameDirectory() {
Common::FSNode node(FileSystemUtil::getUserdataDirectory());
Common::FSNode childNode = node.getChild(SAVEGAME_DIRECTORY);
// Try and return the path using the savegame subfolder. But if doesn't exist, fall back on the data directory
if (childNode.exists())
return childNode.getPath();
return node.getPath();
}
示例10: reportUnknown
static void reportUnknown(const Common::FSNode &path, const SizeMD5Map &filesSizeMD5) {
// TODO: This message should be cleaned up / made more specific.
// For example, we should specify at least which engine triggered this.
//
// Might also be helpful to display the full path (for when this is used
// from the mass detector).
printf("The game in '%s' seems to be unknown.\n", path.getPath().c_str());
printf("Please, report the following data to the ScummVM team along with name\n");
printf("of the game you tried to add and its version/language/etc.:\n");
for (SizeMD5Map::const_iterator file = filesSizeMD5.begin(); file != filesSizeMD5.end(); ++file)
printf(" {\"%s\", 0, \"%s\", %d},\n", file->_key.c_str(), file->_value.md5.c_str(), file->_value.size);
printf("\n");
}
示例11: Config
TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _random("tinsel") {
_vm = this;
_config = new Config(this);
// Register debug flags
DebugMan.addDebugChannel(kTinselDebugAnimations, "animations", "Animations debugging");
DebugMan.addDebugChannel(kTinselDebugActions, "actions", "Actions debugging");
DebugMan.addDebugChannel(kTinselDebugSound, "sound", "Sound debugging");
DebugMan.addDebugChannel(kTinselDebugMusic, "music", "Music debugging");
// Setup mixer
syncSoundSettings();
// Add DW2 subfolder to search path in case user is running directly from the CDs
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "dw2");
// Add subfolders needed for psx versions of Discworld 1
if (TinselV1PSX)
SearchMan.addDirectory(gameDataDir.getPath(), gameDataDir, 0, 3, true);
const GameSettings *g;
const char *gameid = ConfMan.get("gameid").c_str();
for (g = tinselSettings; g->gameid; ++g)
if (!scumm_stricmp(g->gameid, gameid))
_gameId = g->id;
int cd_num = ConfMan.getInt("cdrom");
if (cd_num >= 0)
_system->getAudioCDManager()->openCD(cd_num);
_midiMusic = new MidiMusicPlayer();
_pcmMusic = new PCMMusicPlayer();
_sound = new SoundManager(this);
_bmv = new BMVPlayer();
_mousePos.x = 0;
_mousePos.y = 0;
_keyHandler = NULL;
_dosPlayerDir = 0;
}
示例12: testFolderDownloading
TestExitStatus CloudTests::testFolderDownloading() {
ConfParams.setCloudTestCallbackCalled(false);
ConfParams.setCloudTestErrorCallbackCalled(false);
if (CloudMan.getCurrentStorage() == nullptr) {
Testsuite::logPrintf("Couldn't find connected Storage\n");
return kTestFailed;
}
Common::String info = "Testing Cloud Storage API downloadFolder() method.\n"
"In this test we'll try to download remote 'testbed/' directory.";
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
Testsuite::logPrintf("Info! Skipping test : downloadFolder()\n");
return kTestSkipped;
}
const Common::String &path = ConfMan.get("path");
Common::FSDirectory gameRoot(path);
Common::FSNode node = gameRoot.getFSNode().getChild("downloaded_directory");
Common::String filepath = node.getPath();
if (CloudMan.downloadFolder(
getRemoteTestPath(),
filepath.c_str(),
new Common::GlobalFunctionCallback<Cloud::Storage::FileArrayResponse>(&directoryDownloadedCallback),
new Common::GlobalFunctionCallback<Networking::ErrorResponse>(&errorCallback)
) == nullptr) {
Testsuite::logPrintf("Warning! No Request is returned!\n");
}
if (!waitForCallbackMore()) return kTestSkipped;
Testsuite::clearScreen();
if (ConfParams.isCloudTestErrorCallbackCalled()) {
Testsuite::logPrintf("Error callback was called\n");
return kTestFailed;
}
if (Testsuite::handleInteractiveInput("Was the CloudMan able to download into 'testbed/downloaded_directory'?", "Yes", "No", kOptionRight)) {
Testsuite::logDetailedPrintf("Error! Directory was not downloaded!\n");
return kTestFailed;
}
Testsuite::logDetailedPrintf("Directory was downloaded\n");
return kTestPassed;
}
示例13: checkPath
void PSPSaveFileManager::checkPath(const Common::FSNode &dir) {
const char *savePath = dir.getPath().c_str();
clearError();
PowerMan.beginCriticalSection();
//check if the save directory exists
SceUID fd = sceIoDopen(savePath);
if (fd < 0) {
//No? then let's create it.
sceIoMkdir(savePath, 0777);
} else {
//it exists, so close it again.
sceIoDclose(fd);
}
PowerMan.endCriticalSection();
}
示例14: testSavesSync
TestExitStatus CloudTests::testSavesSync() {
ConfParams.setCloudTestCallbackCalled(false);
ConfParams.setCloudTestErrorCallbackCalled(false);
if (CloudMan.getCurrentStorage() == nullptr) {
Testsuite::logPrintf("Couldn't find connected Storage\n");
return kTestFailed;
}
Common::String info = "Testing Cloud Storage API syncSaves() method.\n"
"In this test we'll try to sync your saves.";
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
Testsuite::logPrintf("Info! Skipping test : syncSaves()\n");
return kTestSkipped;
}
const Common::String &path = ConfMan.get("path");
Common::FSDirectory gameRoot(path);
Common::FSNode node = gameRoot.getFSNode().getChild("downloaded_directory");
Common::String filepath = node.getPath();
if (CloudMan.syncSaves(
new Common::GlobalFunctionCallback<Cloud::Storage::BoolResponse>(&savesSyncedCallback),
new Common::GlobalFunctionCallback<Networking::ErrorResponse>(&errorCallback)
) == nullptr) {
Testsuite::logPrintf("Warning! No Request is returned!\n");
}
if (!waitForCallbackMore()) return kTestSkipped;
Testsuite::clearScreen();
if (ConfParams.isCloudTestErrorCallbackCalled()) {
Testsuite::logPrintf("Error callback was called\n");
return kTestFailed;
}
if (Testsuite::handleInteractiveInput("Was the CloudMan able to sync saves?", "Yes", "No", kOptionRight)) {
Testsuite::logDetailedPrintf("Error! Saves were not synced!\n");
return kTestFailed;
}
Testsuite::logDetailedPrintf("Saves were synced successfully\n");
return kTestPassed;
}
示例15: removeSavefile
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
// Assure the savefile name cache is up-to-date.
assureCached(getSavePath());
if (getError().getCode() != Common::kNoError)
return false;
#ifdef USE_LIBCURL
// Update file's timestamp
Common::HashMap<Common::String, uint32> timestamps = loadTimestamps();
Common::HashMap<Common::String, uint32>::iterator it = timestamps.find(filename);
if (it != timestamps.end()) {
timestamps.erase(it);
saveTimestamps(timestamps);
}
#endif
// Obtain node if exists.
SaveFileCache::const_iterator file = _saveFileCache.find(filename);
if (file == _saveFileCache.end()) {
return false;
} else {
const Common::FSNode fileNode = file->_value;
// Remove from cache, this invalidates the 'file' iterator.
_saveFileCache.erase(file);
file = _saveFileCache.end();
// FIXME: remove does not exist on all systems. If your port fails to
// compile because of this, please let us know (scummvm-devel).
// There is a nicely portable workaround, too: Make this method overloadable.
if (remove(fileNode.getPath().c_str()) != 0) {
#ifndef _WIN32_WCE
if (errno == EACCES)
setError(Common::kWritePermissionDenied, "Search or write permission denied: "+fileNode.getName());
if (errno == ENOENT)
setError(Common::kPathDoesNotExist, "removeSavefile: '"+fileNode.getName()+"' does not exist or path is invalid");
#endif
return false;
} else {
return true;
}
}
}