bool CppFileContents::write(OovStringRef const fn) { SimpleFile file; eOpenStatus openStat = file.open(fn, M_WriteExclusiveTrunc, OE_Binary); OovStatus status(openStat == OS_Opened, SC_File); if(status.ok()) { OovString includeCov = "#include \"OovCoverage.h\""; appendLineEnding(includeCov); updateMemory(); status = file.write(includeCov.c_str(), includeCov.length()); } if(status.ok()) { status = file.write(mFileContents.data(), mFileContents.size()); } if(!status.ok()) { OovString str = "Unable to write %s "; str += fn; str += "\n"; status.report(ET_Error, str.getStr()); } return status.ok(); }
SaveStateList CProjectItem::getSavegameList(const Common::String &target) { Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); Common::StringArray filenames; Common::String saveDesc; Common::String pattern = Common::String::format("%s.0??", target.c_str()); TitanicSavegameHeader header; filenames = saveFileMan->listSavefiles(pattern); sort(filenames.begin(), filenames.end()); // Sort to get the files in numerical order SaveStateList saveList; for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { const char *ext = strrchr(file->c_str(), '.'); int slot = ext ? atoi(ext + 1) : -1; if (slot >= 0 && slot < MAX_SAVEGAME_SLOTS) { Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file); if (in) { SimpleFile f; f.open(in); if (!readSavegameHeader(&f, header)) continue; saveList.push_back(SaveStateDescriptor(slot, header._saveName)); header._thumbnail->free(); delete header._thumbnail; delete in; } } } return saveList; }
SimpleFile *STtitleEngine::open(const CString &name) { Common::SeekableReadStream *stream = g_vm->_filesManager->getResource( CString::format("TEXT/%s", name.c_str())); assert(stream); SimpleFile *file = new SimpleFile(); file->open(stream); return file; }
bool CppFileContents::read(char const *fn) { SimpleFile file; eOpenStatus openStat = file.open(fn, M_ReadWriteExclusive, OE_Binary); OovStatus status(openStat == OS_Opened, SC_File); if(status.ok()) { int size = file.getSize(); mFileContents.resize(size); int actual = 0; status = file.read(mFileContents.data(), size, actual); } if(!status.ok()) { OovString str = "Unable to read %s "; str += fn; str += "\n"; status.report(ET_Error, str.getStr()); } return status.ok(); }