void ExplicitSystemManager::dump_system() { int denominator = std::max((int)options.save_frequency, 1); std::string filename_tail = (boost::format("_%05d") % (iteration_number / denominator)).str(); std::string displacements_filename = (boost::format("%s%s.txt") % options.nodal_displacements_filename % filename_tail).str(); std::string velocities_filename = (boost::format("%s%s.txt") % options.nodal_velocities_filename % filename_tail).str(); std::string forces_filename = (boost::format("%s%s.txt") % options.nodal_forces_filename % filename_tail).str(); save_column_vector(explicit_system->getDisplacements(), displacements_filename); config_doc["nodal_displacements"].SetString(displacements_filename.c_str(), displacements_filename.length()); save_column_vector(explicit_system->getVelocities(), velocities_filename); config_doc["nodal_velocities"].SetString(velocities_filename.c_str(), velocities_filename.length()); save_column_vector(explicit_system->getForces(), forces_filename); config_doc["start_time"].SetDouble(explicit_system->getTime()); config_doc["iteration_number"].SetUint(iteration_number); std::string state_filename((boost::format("%s%s.json") % options.state_filename % filename_tail).str()); std::ofstream out_file(state_filename); if (out_file.is_open()) { rapidjson::OStreamWrapper o_wrapper(out_file); rapidjson::PrettyWriter<rapidjson::OStreamWrapper> writer(o_wrapper); config_doc.Accept(writer); out_file.close(); } else { throw std::runtime_error((boost::format("Unable to open %s.") % state_filename).str()); } }
void Solver<Dtype>::Restore(const char* state_file) { string state_filename(state_file); if (state_filename.size() >= 3 && state_filename.compare(state_filename.size() - 3, 3, ".h5") == 0) { RestoreSolverStateFromHDF5(state_filename); } else { RestoreSolverStateFromBinaryProto(state_filename); } }
void Solver::Restore(const char* state_file) { CHECK(Caffe::root_solver()); string state_filename(state_file); if (state_filename.size() >= 3 && state_filename.compare(state_filename.size() - 3, 3, ".h5") == 0) { RestoreSolverStateFromHDF5(state_filename); } else { RestoreSolverStateFromBinaryProto(state_filename); } }
bool CBoot::Boot_WiiWAD(const std::string& _pFilename) { std::string state_filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_STATE); if (File::Exists(state_filename)) { File::IOFile state_file(state_filename, "r+b"); StateFlags state; state_file.ReadBytes(&state, sizeof(StateFlags)); state.type = 0x03; // TYPE_RETURN state.checksum = state_checksum((u32*)&state.flags, sizeof(StateFlags)-4); state_file.Seek(0, SEEK_SET); state_file.WriteBytes(&state, sizeof(StateFlags)); } else { File::CreateFullPath(state_filename); File::IOFile state_file(state_filename, "a+b"); StateFlags state; memset(&state,0,sizeof(StateFlags)); state.type = 0x03; // TYPE_RETURN state.discstate = 0x01; // DISCSTATE_WII state.checksum = state_checksum((u32*)&state.flags, sizeof(StateFlags)-4); state_file.WriteBytes(&state, sizeof(StateFlags)); } const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(_pFilename); if (!ContentLoader.IsValid()) return false; u64 titleID = ContentLoader.GetTitleID(); // create data directory File::CreateFullPath(Common::GetTitleDataPath(titleID)); if (titleID == TITLEID_SYSMENU) HLE_IPC_CreateVirtualFATFilesystem(); // setup wii mem if (!SetupWiiMemory(ContentLoader.GetCountry())) return false; // DOL const DiscIO::SNANDContent* pContent = ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()); if (pContent == nullptr) return false; WII_IPC_HLE_Interface::SetDefaultContentFile(_pFilename); std::unique_ptr<CDolLoader> pDolLoader; if (pContent->m_pData) { pDolLoader.reset(new CDolLoader(pContent->m_pData, pContent->m_Size)); } else { pDolLoader.reset(new CDolLoader(pContent->m_Filename)); } pDolLoader->Load(); PC = pDolLoader->GetEntryPoint() | 0x80000000; // Pass the "#002 check" // Apploader should write the IOS version and revision to 0x3140, and compare it // to 0x3188 to pass the check, but we don't do it, and i don't know where to read the IOS rev... // Currently we just write 0xFFFF for the revision, copy manually and it works fine :p // TODO : figure it correctly : where should we read the IOS rev that the wad "needs" ? Memory::Write_U16(ContentLoader.GetIosVersion(), 0x00003140); Memory::Write_U16(0xFFFF, 0x00003142); Memory::Write_U32(Memory::Read_U32(0x00003140), 0x00003188); // Load patches and run startup patches const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(_pFilename); if (pVolume != nullptr) PatchEngine::LoadPatches(); return true; }