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


C++ fstream::close方法代码示例

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


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

示例1: Fini

VOID Fini(INT32 code, VOID *v) {
	PRINT_SCN ("All applications are at the end" << "...");
    #ifdef LOG_ASSEM
     TraceFile.close();
    #endif
    MemFile.close();
}
开发者ID:cinwell,项目名称:pin_assem,代码行数:7,代码来源:pinAssem.cpp

示例2: createWalletFile

void createWalletFile(std::fstream& walletFile, const std::string& filename) {
  walletFile.open(filename.c_str(), std::fstream::in | std::fstream::out | std::fstream::binary);
  if (walletFile) {
    walletFile.close();
    throw std::runtime_error("Wallet file already exists");
  }

  walletFile.open(filename.c_str(), std::fstream::out);
  walletFile.close();

  walletFile.open(filename.c_str(), std::fstream::in | std::fstream::out | std::fstream::binary);
}
开发者ID:inmoney,项目名称:bytecoin,代码行数:12,代码来源:WalletService.cpp

示例3: saveAllCellsToCsv

void ScientificProcessor::saveAllCellsToCsv(std::fstream &filestr)
{
    std::map<int, std::vector<double> > firstTime = allCells.begin()->second;
    std::vector<double> firstCell = firstTime.begin()->second;
    std::cout << firstCell.size() << std::endl;
    int nfl = (firstCell.size() - 9)/2;

    /* Header */
    filestr << "t, label, tp, parent, cx, cy, h, w, area, angle, ";
    for(unsigned int i = 0; i < nfl; i++)
        filestr << "flav" << i << ", flsd" << i << ", ";
    filestr << std::endl;

    /* Data */
    for(std::map<int, std::map<int, std::vector<double> > >::iterator it = allCells.begin();
        it != allCells.end(); ++it) {
        int t = it->first;
        std::map<int, std::vector<double> > currentTime = it->second;
        for(std::map<int, std::vector<double> >::iterator itm = currentTime.begin();
            itm != currentTime.end(); ++itm) {
            std::vector<double> features = itm->second;
            filestr << t << ",";
            for(std::vector<double>::iterator itv = features.begin();
                 itv != features.end(); ++itv) {
                filestr << *itv << ",";
            }
            filestr << std::endl;
        }
    }
    filestr.close();
}
开发者ID:tmramalho,项目名称:bigCellBrotherGUI,代码行数:31,代码来源:ScientificProcessor.cpp

示例4: open

   void open() {
      //
      //    open file in out mode, close and open again in out/in mode
      //
      for (int ilayer=0; ilayer<4; ++ilayer) {
         vname[ilayer] << "temporary_file_v" << ilayer << "file-" << std::setfill('0') << std::setw(3) << angle << ".dat";
         tname[ilayer] << "temporary_file_t" << ilayer << "file-" << std::setfill('0') << std::setw(3) << angle << ".dat";
         uname[ilayer] << "temporary_file_u" << ilayer << "file-" << std::setfill('0') << std::setw(3) << angle << ".dat";

         vfile[ilayer] = new fstream(vname[ilayer].str().c_str(), std::ios::binary | std::ios::out);
         vfile[ilayer]->close();
         vfile[ilayer]->open(vname[ilayer].str().c_str(), std::ios::binary | std::ios::in | std::ios::out);

         tfile[ilayer] = new fstream(tname[ilayer].str().c_str(), std::ios::binary | std::ios::out);
         tfile[ilayer]->close();
         tfile[ilayer]->open(tname[ilayer].str().c_str(), std::ios::binary | std::ios::in | std::ios::out);

         ufile[ilayer] = new fstream(uname[ilayer].str().c_str(), std::ios::binary | std::ios::out);
         ufile[ilayer]->close();
         ufile[ilayer]->open(uname[ilayer].str().c_str(), std::ios::binary | std::ios::in | std::ios::out);
      }
      wname << "temporary_file_wfile-" << std::setfill('0') << std::setw(3) << angle << ".dat";
      wfile = new fstream(wname.str().c_str(), std::ios::binary | std::ios::out);
      wfile->close();
      wfile->open(wname.str().c_str(), std::ios::binary | std::ios::in | std::ios::out);
   }
开发者ID:BlakeSchultze,项目名称:DataFormat-v44,代码行数:26,代码来源:writeReco.cpp

示例5: getFILE

// getFILE is a wrapper for getting files
bool getFILE(std::fstream &fp, const char* fname, const char* mode)
{
	int writeFile = 0;
	if (strcmp(mode, "out") == 0)
	{
		writeFile = 1;
		if(writeFile && fexists(fname))
		{
			fprintf(stderr,"File already exists: %s\n",fname);
			return false;
		}

		fp.open(fname, std::ios::out);
	}
	else if (strcmp(mode, "app") == 0)
		fp.open(fname, std::ios::app);
	else if (strcmp(mode, "in") == 0)
		fp.open(fname, std::ios::in);

	if( !fp )
	{
		fprintf(stderr,"Error opening FILE handle for file: %s\n",fname);
		fp.close();
		return false;
	}
	return true;
}
开发者ID:tplinderoth,项目名称:ngsParalog,代码行数:28,代码来源:generalUtils.cpp

示例6: file

void
getstat(const std::string& pid,std::fstream& tsdbfile,std::string metric)//Get memmemory information (in one block right now)
{

    std::string dummy,minflt,mjflt,utime,s_time,nthreads,vsize,rss,iodelay;
    char state;
    std::string path="/proc/"+pid+"/stat";
    std::ifstream file(path,std::ifstream::binary);
    file>>dummy>>dummy>>state>>dummy>>dummy>>dummy>>dummy>>dummy>>dummy>>minflt>>dummy>>mjflt>>dummy>>utime>>s_time>>dummy>>dummy>>dummy>>dummy>>nthreads>>dummy>>dummy>>vsize>>rss;
    metric+=".stat";
    std::string st_int;
    switch(state){
        case 'R':
        st_int="1";break;
        case 'S':
        st_int="2"; break;
        case 'D':
        st_int="3"; break;
        case 'T':
        st_int="4"; break;
        default:
        st_int="0";

    }
    tsdbfile.open ("tcollector_proc.out",std::fstream::app);
    tsdb_stdout(tsdbfile,metric+".state",st_int);
    tsdb_stdout(tsdbfile,metric+".minflt",minflt);
    tsdb_stdout(tsdbfile,metric+".mjrflt",mjflt);
    tsdb_stdout(tsdbfile,metric+".utime",utime);
    tsdb_stdout(tsdbfile,metric+".stime",s_time);
    tsdb_stdout(tsdbfile,metric+".nthreads",nthreads);
    tsdbfile.close();

    return;
}
开发者ID:apmechev,项目名称:procfsamp,代码行数:35,代码来源:procfscollector.cpp

示例7: Close

exp bool Close() {
    // Update FS info before unmounting the disk
    WriteFSInfo();
    f.close();

    return true;
}
开发者ID:Rohansi,项目名称:LoonyOS,代码行数:7,代码来源:main.cpp

示例8: verifiedOC

// Ensures the file is opened/closed properly and retries 5 times.
// if choice is false, the file is closed and if it is 1, the file is opened.
bool verifiedOC ( std::fstream& file, std::string fileDir, bool choice, std::ios::openmode io ) {
    unsigned int i = 0; // Declaring a counter variable.
    
    // Choice determines if we are opening or closing the file. (True to open, False to close)
    if ( choice ) {
        do {
            file.open ( fileDir.c_str(), io );  // Open file as user selection.
            if ( file.is_open() ) {
                return true;
            } else {
                // Prints that the attempt to change the file state has failed.
                std::cout << "The file " << fileDir.c_str() << " failed to open... Retrying " << ++i << "\n";
            }
        
            // Will exit the loop after the the number of attempts FILE_OPEN_RETRIES specifies.
            if ( i >= FILE_OPEN_RETRIES ) {
                std::cout << "The file " << fileDir.c_str() << " failed to change open." << std::endl;
                return false;
            }
        } while ( !file.is_open() );
    } else {
        file.close();
    }
    
    return true;
}
开发者ID:Denakee,项目名称:CS10A,代码行数:28,代码来源:deck.cpp

示例9: StoreCurrentFitnessInPopulation

void StoreCurrentFitnessInPopulation(Fitnesses& fitness, std::fstream& fitnessEachGeneration) {
  fitnessEachGeneration.open("FitnessEachGeneration.txt", std::fstream::in | std::fstream::out | std::fstream::app);
  int populationSize = fitness.size();
  for(int i=0;i<populationSize;i++) {
    fitnessEachGeneration << fitness[i] <<'\n';
  }	
  fitnessEachGeneration.close();
}
开发者ID:carthikvenkataraman,项目名称:MasterThesis-PropOpt,代码行数:8,代码来源:GeneticAlgorithm.cpp

示例10: close

 void close() {
    for (int ilayer=0; ilayer<4; ++ilayer) {
       vfile[ilayer]->close();
       tfile[ilayer]->close();
       ufile[ilayer]->close();
    }
    wfile->close();
 }
开发者ID:BlakeSchultze,项目名称:DataFormat-v44,代码行数:8,代码来源:writeReco.cpp

示例11: write_file

void PcieAccessInterfaceTest::write_file(char* data, const std::string& path, uint32_t size, uint32_t offset) {
    memory_file.open(path,  std::ios::out |std::ios::binary | std::ios::trunc);
    if (memory_file.is_open()) {
        memory_file.seekg(offset, std::ios::beg);
        memory_file.write(data, size);
        memory_file.close();
    }
}
开发者ID:01org,项目名称:intelRSD,代码行数:8,代码来源:pcie_access_interface_test.cpp

示例12: createAndOpen

void createAndOpen(std::fstream& file, std::string name){
  if (!exists(name.c_str())){
    file.open(name.c_str(), std::fstream::out | 
                            std::fstream::binary);
    file.close();
  }
  file.open(name.c_str(), std::fstream::in | std::fstream::out |
                          std::fstream::binary);
}
开发者ID:elenaod,项目名称:KVStore,代码行数:9,代码来源:KVStore.cpp

示例13: finishwithfile

/*! \brief Close and truncate the file, and update digest
 * Truncation is needed to remove any detritus from previously-saved states.
 */
void resultsfile::finishwithfile(std::fstream& file)
   {
   std::streampos length = file.tellp();
   // close and truncate file
   file.close();
   truncate(length);
   // re-open and update digest
   file.open(fname.c_str(), std::ios::in);
   filedigest.process(file);
   }
开发者ID:jyzhang-bjtu,项目名称:simcommsys,代码行数:13,代码来源:resultsfile.cpp

示例14: NMPRK_StopDebugLogging

NMPRKC_API nmprk_status_t NMPRK_StopDebugLogging()
{
	if(si_fsDebugLog.is_open() == true)
	{
		SI_DEBUG_INFO(SI_THIS_MODULE, "Debug Logging Stopped");
		si_fsDebugLog.close();
	}

	return NMPRK_SUCCESS;
}
开发者ID:01org,项目名称:NMPRK,代码行数:10,代码来源:nmprkC.cpp

示例15: init

/**
 * Initializes the hash function, with a file stream value.
 *
 * @param fileStream The stream value to be used for computation.
 * @param closeStream If the file stream should be closed at end, if false
 * the file stream is positioned at the initial position.
 */
void HashFunction::init(std::fstream &fileStream, bool closeStream) {
    // calls the stream init method
    this->init((std::istream &) fileStream);

    // in case the file stream should be closed
    if(closeStream) {
        // closes the file stream
        fileStream.close();
    }
}
开发者ID:gamedevforks,项目名称:mariachi,代码行数:17,代码来源:hash_function.cpp


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