本文整理汇总了C++中FileManager::getAbsFilePath方法的典型用法代码示例。如果您正苦于以下问题:C++ FileManager::getAbsFilePath方法的具体用法?C++ FileManager::getAbsFilePath怎么用?C++ FileManager::getAbsFilePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::getAbsFilePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveReplay
// Format of saved replay file:
// | replay version
// | stage name length | stage name | stage width | stage height
// | num walls | <walls>
// | num zones | <zones>
// | num ships | <ship properties>
// | num ship adds | <ship adds>
// | num ship removes | <ship removes>
// | num ship show names | <show names>
// | num ship hide names | <hide names>
// | num ship show energys | <show energys>
// | num ship hide energys | <hide energys>
// | num ship ticks | <ship ticks>
// | num laser starts | <laser starts>
// | num laser ends | <laser ends>
// | num laser sparks | <laser sparks>
// | num torpedo starts | <torpedo starts>
// | num torpedo ends | <torpedo ends>
// | num torpedo blasts | <torpedo blasts>
// | num torpedo debris | <torpedo debris>
// | num ship destroys | <ship destroys>
// | num texts | <texts>
// | num log entries | <log entries>
// | num results | <results>
void ReplayBuilder::saveReplay(const char *dir, const char *filename) {
// TODO: throw exceptions for failing to save replay, don't silently fail
FileManager fileManager;
char *replayTemplate = 0;
char *templatePath = getResourcePath(REPLAY_TEMPLATE);
if (templatePath != 0) {
try {
replayTemplate = fileManager.readFile(templatePath);
} catch (FileNotFoundException *e) {
delete e;
}
delete templatePath;
}
if (replayTemplate != 0) {
copyReplayResource(KINETIC_JS, dir);
copyReplayResource(BBREPLAY_JS, dir);
std::string replayHtml(replayTemplate);
std::string title = htmlTitle();
size_t i;
size_t len = strlen(REPLAY_TITLE_PLACEHOLDER);
i = replayHtml.find(REPLAY_TITLE_PLACEHOLDER, 0);
if (i != std::string::npos) {
replayHtml.replace(i, len, htmlTitle());
}
len = strlen(REPLAY_DATA_PLACEHOLDER);
i = replayHtml.find(REPLAY_DATA_PLACEHOLDER, 0);
if (i != std::string::npos) {
replayHtml.replace(i, len, buildReplayDataString());
}
len = strlen(EXTRA_JS_PLACEHOLDER);
i = replayHtml.find(EXTRA_JS_PLACEHOLDER, 0);
if (i != std::string::npos) {
replayHtml.replace(i, len, extraJavascript_ == 0 ? "" : extraJavascript_);
}
char *filePath = fileManager.getFilePath(dir, filename);
char *absFilename = fileManager.getAbsFilePath(filePath);
delete filePath;
fileManager.writeFile(absFilename, replayHtml.c_str());
delete absFilename;
delete replayTemplate;
}
}
示例2: main
int main(int argc, char *argv[]) {
Zipper *zipper = new GuiZipper();
FileManager *fileManager = new FileManager(zipper);
CliPackageReporter *packageReporter = new CliPackageReporter();
fileManager->setListener(packageReporter);
char *shipsBaseDir = fileManager->getAbsFilePath(SHIPS_SUBDIR);
char *stagesBaseDir = fileManager->getAbsFilePath(STAGES_SUBDIR);
if (flagExists(argc, argv, "packstage")) {
char **stageInfo = parseFlag(argc, argv, "packstage", 2);
if (stageInfo == 0) {
printUsage();
} else {
// TODO: add a new flag for obfuscating source code
bool obfuscate = false;
try {
char *stageAbsName = fileManager->getAbsFilePath(stageInfo[0]);
char *stageName =
fileManager->parseRelativeFilePath(stagesBaseDir, stageAbsName);
if (stageName == 0) {
std::cout << "Stage must be located under " << STAGES_SUBDIR
<< "/ subdirectory: " << stageInfo[0] << std::endl;
} else {
fileManager->packageStage(stagesBaseDir, stageName, stageInfo[1],
CACHE_SUBDIR, TMP_SUBDIR, obfuscate, true);
delete stageName;
}
delete stageAbsName;
} catch (std::exception *e) {
std::cout << "BerryBots encountered an error:" << std::endl;
std::cout << " " << e->what() << std::endl;
delete e;
}
delete stageInfo;
}
return 0;
}
if (flagExists(argc, argv, "packbot")) {
char **shipInfo = parseFlag(argc, argv, "packbot", 2);
if (shipInfo == 0) {
printUsage();
} else {
// TODO: add a new flag for obfuscating source code
bool obfuscate = false;
try {
char *shipAbsName = fileManager->getAbsFilePath(shipInfo[0]);
char *shipName =
fileManager->parseRelativeFilePath(shipsBaseDir, shipAbsName);
if (shipName == 0) {
std::cout << "Ship must be located under " << SHIPS_SUBDIR
<< "/ subdirectory: " << shipInfo[0] << std::endl;
} else {
fileManager->packageShip(shipsBaseDir, shipName, shipInfo[1],
CACHE_SUBDIR, TMP_SUBDIR, obfuscate, true);
delete shipName;
}
delete shipAbsName;
} catch (std::exception *e) {
std::cout << "BerryBots encountered an error:" << std::endl;
std::cout << " " << e->what() << std::endl;
delete e;
}
delete shipInfo;
}
return 0;
}
bool nodisplay = flagExists(argc, argv, "nodisplay");
bool saveReplay = flagExists(argc, argv, "savereplay");
int optArgsOffset = (nodisplay ? 1 : 0) + (saveReplay ? 1 : 0);
if (argc < 3 + optArgsOffset) {
printUsage();
}
srand(time(NULL));
CliPrintHandler *printHandler = new CliPrintHandler();
BerryBotsEngine *engine =
new BerryBotsEngine(printHandler, fileManager, resourcePath().c_str());
Stage *stage = engine->getStage();
char *stageAbsName = fileManager->getAbsFilePath(argv[1 + optArgsOffset]);
char *stageName =
fileManager->parseRelativeFilePath(stagesBaseDir, stageAbsName);
if (stageName == 0) {
std::cout << "Stage must be located under " << STAGES_SUBDIR
<< "/ subdirectory: " << argv[1 + optArgsOffset] << std::endl;
return 0;
}
try {
engine->initStage(stagesBaseDir, stageName, CACHE_SUBDIR);
} catch (EngineException *e) {
delete stageAbsName;
delete stageName;
std::cout << "BerryBots initialization failed:" << std::endl;
std::cout << " " << e->what() << std::endl;
delete e;
return 0;
}
//.........这里部分代码省略.........