本文整理汇总了C++中FileManager::fileExists方法的典型用法代码示例。如果您正苦于以下问题:C++ FileManager::fileExists方法的具体用法?C++ FileManager::fileExists怎么用?C++ FileManager::fileExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::fileExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyReplayResource
void ReplayBuilder::copyReplayResource(const char *resource,
const char *targetDir) {
FileManager fileManager;
char *localResource = new char[strlen(resource) + 1];
strcpy(localResource, resource);
fileManager.fixSlashes(localResource);
char *filename = fileManager.parseFilename(localResource);
delete localResource;
char *targetPath = fileManager.getFilePath(targetDir, filename);
delete filename;
if (!fileManager.fileExists(targetPath)) {
char *resourcePath = getResourcePath(resource);
if (resourcePath != 0) {
char *s = 0;
try {
s = fileManager.readFile(resourcePath);
} catch (FileNotFoundException *e) {
delete e;
}
if (s != 0) {
fileManager.writeFile(targetPath, s);
delete s;
}
delete resourcePath;
}
}
delete targetPath;
}
示例2: resourcePath
std::string resourcePath() {
FileManager fileManager;
if (fileManager.fileExists("/usr/share/berrybots")) {
return std::string("/usr/share/berrybots/");
} else {
return "./";
}
}
示例3: main
//.........这里部分代码省略.........
TeamResult *result = &(rankedTeams[x]->result);
if (result->showResult) {
std::cout << " " << rankedTeams[x]->name << ":" << std::endl;
std::cout << " Rank: ";
if (result->rank == 0) {
std::cout << "-";
} else {
std::cout << result->rank;
}
std::cout << std::endl;
if (hasScores) {
std::cout << " Score: " << round(result->score, 2) << std::endl;
}
for (int y = 0; y < numStats; y++) {
char *key = statKeys[y];
bool found = false;
for (int z = 0; z < result->numStats; z++) {
char *resultKey = result->stats[z]->key;
if (strcmp(key, resultKey) == 0) {
std::cout << " " << key << ": "
<< round(result->stats[z]->value, 2) << std::endl;
found = true;
break;
}
}
if (!found) {
std::cout << " " << key << ": -" << std::endl;
}
}
}
}
std::cout << std::endl << "CPU time used per tick (microseconds):"
<< std::endl;
for (int x = 0; x < engine->getNumTeams(); x++) {
Team *team = engine->getTeam(x);
if (!team->stageShip && !team->disabled) {
std::cout << " " << team->name << ": "
<< (team->totalCpuTime / team->totalCpuTicks) << std::endl;
}
}
if (realSeconds > 0) {
std::cout << std::endl << "TPS: "
<< (((double) engine->getGameTime()) / realSeconds) << std::endl;
}
if (saveReplay) {
ReplayBuilder *replayBuilder = engine->getReplayBuilder();
// TODO: move this into a function in the engine
Team **rankedTeams = engine->getRankedTeams();
replayBuilder->setResults(rankedTeams, engine->getNumTeams());
char *filename = 0;
char *absFilename = 0;
do {
if (filename != 0) {
delete filename;
}
if (absFilename != 0) {
delete absFilename;
}
filename = replayFilename(stage->getName());
char *filePath = fileManager->getFilePath(REPLAYS_SUBDIR, filename);
absFilename = fileManager->getAbsFilePath(filePath);
delete filePath;
} while (fileManager->fileExists(absFilename));
replayBuilder->saveReplay(filename);
std::cout << std::endl << "Saved replay to: " << REPLAYS_SUBDIR << "/"
<< filename << std::endl;
delete filename;
delete absFilename;
}
std::cout << std::endl;
delete engine;
for (int x = 0; x < numTeams; x++) {
delete teams[x];
}
delete teams;
delete rankedTeams;
for (int x = 0; x < numStats; x++) {
delete statKeys[x];
}
delete statKeys;
delete printHandler;
if (!nodisplay) {
delete gfxManager;
}
delete packageReporter;
delete fileManager;
delete zipper;
delete shipsBaseDir;
delete stagesBaseDir;
return 0;
}