当前位置: 首页>>代码示例>>C++>>正文


C++ SaveFileManager::renameSavefile方法代码示例

本文整理汇总了C++中common::SaveFileManager::renameSavefile方法的典型用法代码示例。如果您正苦于以下问题:C++ SaveFileManager::renameSavefile方法的具体用法?C++ SaveFileManager::renameSavefile怎么用?C++ SaveFileManager::renameSavefile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common::SaveFileManager的用法示例。


在下文中一共展示了SaveFileManager::renameSavefile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: removeSaveState

void PictureMetaEngine::removeSaveState(const char *target, int slot) const {
    // Slot 0 can't be deleted, it's for restarting the game(s)
    if (slot == 0)
        return;

    Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
    Common::String filename = Picture::PictureEngine::getSavegameFilename(target, slot);

    saveFileMan->removeSavefile(filename.c_str());

    Common::StringArray filenames;
    Common::String pattern = target;
    pattern += ".???";
    filenames = saveFileMan->listSavefiles(pattern.c_str());
    Common::sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..)

    for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
        // Obtain the last 3 digits of the filename, since they correspond to the save slot
        int slotNum = atoi(file->c_str() + file->size() - 3);

        // Rename every slot greater than the deleted slot,
        // Also do not rename quicksaves.
        if (slotNum > slot && slotNum < 990) {
            // FIXME: Our savefile renaming done here is inconsitent with what we do in
            // GUI_v2::deleteMenu. While here we rename every slot with a greater equal
            // number of the deleted slot to deleted slot, deleted slot + 1 etc.,
            // we only rename the following slots in GUI_v2::deleteMenu until a slot
            // is missing.
            saveFileMan->renameSavefile(file->c_str(), filename.c_str());

            filename = Picture::PictureEngine::getSavegameFilename(target, ++slot);
        }
    }

}
开发者ID:bluegr,项目名称:scummvm-picture,代码行数:35,代码来源:detection.cpp

示例2: testRenamingSavefile

TestExitStatus SaveGametests::testRenamingSavefile() {
	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	// Open a file for renaming
	if (!writeDataToFile("tBedSomeWeirdName.0", "Rename me!")) {
		Testsuite::logDetailedPrintf("Writing data to savefile failed\n");
		return kTestFailed;
	}

	// Rename it
	saveFileMan->renameSavefile("tBedSomeWeirdName.0", "tBedSomeCoolName.0");

	// Verify if it contains the same data
	if (!readAndVerifyData("tBedSomeCoolName.0", "Rename me!")) {
		Testsuite::logDetailedPrintf("Renaming savefile failed\n");
		return kTestFailed;
	}

	return kTestPassed;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:19,代码来源:savegame.cpp

示例3: removeSaveState

void ToltecsMetaEngine::removeSaveState(const char *target, int slot) const {
	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	Common::String filename = Toltecs::ToltecsEngine::getSavegameFilename(target, slot);

	saveFileMan->removeSavefile(filename.c_str());

	Common::StringArray filenames;
	Common::String pattern = target;
	pattern += ".###";
	filenames = saveFileMan->listSavefiles(pattern.c_str());
	Common::sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..)

	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
		// Obtain the last 3 digits of the filename, since they correspond to the save slot
		int slotNum = atoi(file->c_str() + file->size() - 3);

		// Rename every slot greater than the deleted slot,
		if (slotNum > slot) {
			saveFileMan->renameSavefile(file->c_str(), filename.c_str());
			filename = Toltecs::ToltecsEngine::getSavegameFilename(target, ++slot);
		}
	}
}
开发者ID:Cruel,项目名称:scummvm,代码行数:23,代码来源:detection.cpp


注:本文中的common::SaveFileManager::renameSavefile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。