/*Function to enter a filename that has to be restored. Input:void Output:int */ int restore_file() { int fd_cat = -1; int ret = -1; char* path = NULL; printf("\ndeduped files\n"); ret=readfilecatalog(); if (ret== -1) { goto out; } path=(char*)calloc(1,FILE_SIZE); out4:printf("\nEnter the exact and full path of dedup file to be restored\n"); scanf("%s",path); ret=comparepath(path); if (ret== -1) { goto out; } if (ret== 1) { printf("\nPlease enter valid full path of file"); goto out4; } ret=restorefile(path); if (ret== -1) { goto out; } ret=0; out: clean_buff(&path); return ret; }
void BlackoilOutputWriter:: restore(SimulatorTimerInterface& timer, BlackoilState& state, WellStateFullyImplicitBlackoil& wellState, const std::string& filename, const int desiredResportStep ) { std::ifstream restorefile( filename.c_str() ); if( restorefile ) { std::cout << "============================================================================"<<std::endl; std::cout << "Restoring from "; if( desiredResportStep < 0 ) { std::cout << "last"; } else { std::cout << desiredResportStep; } std::cout << " report step! filename = " << filename << std::endl << std::endl; int reportStep; restorefile.read( (char *) &reportStep, sizeof(int) ); const int readReportStep = (desiredResportStep < 0) ? std::numeric_limits<int>::max() : desiredResportStep; while( reportStep <= readReportStep && ! timer.done() && restorefile ) { restorefile >> state; restorefile >> wellState; // No per cell data is written for restore steps, but will be // for subsequent steps, when we have started simulating writeTimeStepWithoutCellProperties( timer, state, wellState ); // some output std::cout << "Restored step " << timer.reportStepNum() << " at day " << unit::convert::to(timer.simulationTimeElapsed(),unit::day) << std::endl; if( readReportStep == reportStep ) { break; } // if the stream is not valid anymore we just use the last state read if( ! restorefile ) { std::cerr << "Reached EOF, using last state read!" << std::endl; break; } // try to read next report step restorefile.read( (char *) &reportStep, sizeof(int) ); // if read failed, exit loop if( ! restorefile ) { break; } // next step timer.advance(); if( timer.reportStepNum() != reportStep ) { break; } } } else {