本文整理汇总了C++中common::SaveFileManager::removeSavefile方法的典型用法代码示例。如果您正苦于以下问题:C++ SaveFileManager::removeSavefile方法的具体用法?C++ SaveFileManager::removeSavefile怎么用?C++ SaveFileManager::removeSavefile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::SaveFileManager
的用法示例。
在下文中一共展示了SaveFileManager::removeSavefile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveSavegameData
Common::Error saveSavegameData(int saveGameIdx, const Common::String &saveName, DraciEngine &vm) {
Common::String filename = vm.getSavegameFile(saveGameIdx);
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
Common::OutSaveFile *f = saveMan->openForSaving(filename);
if (f == NULL)
return Common::kNoGameDataFoundError;
TimeDate curTime;
vm._system->getTimeAndDate(curTime);
// Save the savegame header
DraciSavegameHeader header;
header.saveName = saveName;
header.date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
header.time = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
header.playtime = vm.getTotalPlayTime() / 1000;
writeSavegameHeader(f, header);
if (f->err()) {
delete f;
saveMan->removeSavefile(filename);
return Common::kWritingFailed;
} else {
// Create the remainder of the savegame
Common::Serializer s(NULL, f);
vm._game->DoSync(s);
f->finalize();
delete f;
return Common::kNoError;
}
}
示例2: 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);
}
}
}
示例3: delete_savegame
void delete_savegame(EngineState *s, int savedir_nr) {
Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_nr);
//printf("Deleting savegame '%s'\n", filename.c_str());
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
saveFileMan->removeSavefile(filename);
}
示例4: removeSaveState
void SkyMetaEngine::removeSaveState(const char *target, int slot) const {
if (slot == 0) // do not delete the auto save
return;
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
char fName[20];
sprintf(fName,"SKY-VM.%03d", slot - 1);
saveFileMan->removeSavefile(fName);
// Load current save game descriptions
Common::StringArray savenames;
savenames.resize(MAX_SAVE_GAMES+1);
Common::InSaveFile *inf;
inf = saveFileMan->openForLoading("SKY-VM.SAV");
if (inf != NULL) {
char *tmpBuf = new char[MAX_SAVE_GAMES * MAX_TEXT_LEN];
char *tmpPtr = tmpBuf;
inf->read(tmpBuf, MAX_SAVE_GAMES * MAX_TEXT_LEN);
for (int i = 0; i < MAX_SAVE_GAMES; ++i) {
savenames[i] = tmpPtr;
tmpPtr += savenames[i].size() + 1;
}
delete inf;
delete[] tmpBuf;
}
// Update the save game description at the given slot
savenames[slot - 1] = "";
// Save the updated descriptions
Common::OutSaveFile *outf;
outf = saveFileMan->openForSaving("SKY-VM.SAV");
bool ioFailed = true;
if (outf) {
for (uint16 cnt = 0; cnt < MAX_SAVE_GAMES; cnt++) {
outf->write(savenames[cnt].c_str(), savenames[cnt].size() + 1);
}
outf->finalize();
if (!outf->err())
ioFailed = false;
delete outf;
}
if (ioFailed)
warning("Unable to store Savegame names to file SKY-VM.SAV. (%s)", saveFileMan->popErrorDesc().c_str());
}
示例5: testRemovingSavefile
TestExitStatus SaveGametests::testRemovingSavefile() {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
// Create a dummy savefile
if (!writeDataToFile("tBedSavefileToRemove.0", "Dummy Savefile!")) {
Testsuite::logDetailedPrintf("Writing data to savefile failed\n");
return kTestFailed;
}
// Remove it
saveFileMan->removeSavefile("tBedSavefileToRemove.0");
// Try opening it Now
Common::InSaveFile *loadFile = saveFileMan->openForLoading("saveFile.0");
if (loadFile) {
// Removing failed
Testsuite::logDetailedPrintf("Removing savefile failed\n");
return kTestFailed;
}
return kTestPassed;
}
示例6: 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);
}
}
}
示例7: removeGameState
Common::Error NeverhoodEngine::removeGameState(int slot) {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::String filename = Neverhood::NeverhoodEngine::getSavegameFilename(_targetName, slot);
saveFileMan->removeSavefile(filename.c_str());
return Common::kNoError;
}
示例8: removeSaveState
void NeverhoodMetaEngine::removeSaveState(const char *target, int slot) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::String filename = Neverhood::NeverhoodEngine::getSavegameFilename(target, slot);
saveFileMan->removeSavefile(filename.c_str());
}
示例9: removeSaveState
void LabMetaEngine::removeSaveState(const char *target, int slot) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
saveFileMan->removeSavefile(Common::String::format("%s.%03u", target, slot));
}
示例10: kFileIO
reg_t kFileIO(EngineState *s, int funct_nr, int argc, reg_t *argv) {
int func_nr = argv[0].toUint16();
switch (func_nr) {
case K_FILEIO_OPEN : {
char *name = kernel_dereference_char_pointer(s, argv[1], 0);
int mode = argv[2].toUint16();
file_open(s, name, mode);
debug(3, "K_FILEIO_OPEN(%s,0x%x)", name, mode);
break;
}
case K_FILEIO_CLOSE : {
int handle = argv[1].toUint16();
debug(3, "K_FILEIO_CLOSE(%d)", handle);
file_close(s, handle);
break;
}
case K_FILEIO_READ_RAW : {
int handle = argv[1].toUint16();
char *dest = kernel_dereference_char_pointer(s, argv[2], 0);
int size = argv[3].toUint16();
debug(3, "K_FILEIO_READ_RAW(%d,%d)", handle, size);
fread_wrapper(s, dest, size, handle);
break;
}
case K_FILEIO_WRITE_RAW : {
int handle = argv[1].toUint16();
char *buf = kernel_dereference_char_pointer(s, argv[2], 0);
int size = argv[3].toUint16();
debug(3, "K_FILEIO_WRITE_RAW(%d,%d)", handle, size);
fwrite_wrapper(s, handle, buf, size);
break;
}
case K_FILEIO_UNLINK : {
char *name = kernel_dereference_char_pointer(s, argv[1], 0);
debug(3, "K_FILEIO_UNLINK(%s)", name);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
const Common::String wrappedName = ((Sci::SciEngine*)g_engine)->wrapFilename(name);
saveFileMan->removeSavefile(wrappedName);
// TODO/FIXME: Should we return something (like, a bool indicating
// whether deleting the save succeeded or failed)?
break;
}
case K_FILEIO_READ_STRING : {
char *dest = kernel_dereference_char_pointer(s, argv[1], 0);
int size = argv[2].toUint16();
int handle = argv[3].toUint16();
debug(3, "K_FILEIO_READ_STRING(%d,%d)", handle, size);
fgets_wrapper(s, dest, size, handle);
return argv[1];
}
case K_FILEIO_WRITE_STRING : {
int handle = argv[1].toUint16();
int size = argv[3].toUint16();
char *buf = kernel_dereference_char_pointer(s, argv[2], size);
debug(3, "K_FILEIO_WRITE_STRING(%d,%d)", handle, size);
// FIXME: What is the difference between K_FILEIO_WRITE_STRING and
// K_FILEIO_WRITE_RAW? Normally, I would expect the difference to
// be that the former doesn't receive a 'size' parameter. But here
// it does. Are we missing something?
if (buf)
fwrite_wrapper(s, handle, buf, size);
break;
}
case K_FILEIO_SEEK : {
int handle = argv[1].toUint16();
int offset = argv[2].toUint16();
int whence = argv[3].toUint16();
debug(3, "K_FILEIO_SEEK(%d,%d,%d)", handle, offset, whence);
fseek_wrapper(s, handle, offset, whence);
break;
}
case K_FILEIO_FIND_FIRST : {
char *mask = kernel_dereference_char_pointer(s, argv[1], 0);
reg_t buf = argv[2];
int attr = argv[3].toUint16(); // We won't use this, Win32 might, though...
debug(3, "K_FILEIO_FIND_FIRST(%s,0x%x)", mask, attr);
#ifndef WIN32
if (strcmp(mask, "*.*") == 0)
strcpy(mask, "*"); // For UNIX
#endif
s->_dirseeker.firstFile(mask, buf);
break;
}
case K_FILEIO_FIND_NEXT : {
debug(3, "K_FILEIO_FIND_NEXT()");
s->_dirseeker.nextFile();
break;
}
case K_FILEIO_FILE_EXISTS : {
//.........这里部分代码省略.........