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


C++ ifstream::tellg方法代码示例

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


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

示例1: bytesRemainingToTheEnd

// This utilitu function returns the bytes remaining until the end of the file
// is reached. It should be probably made publicly availale in a separate util
// section of the library (e.g. util/io.h)
size_t bytesRemainingToTheEnd(ifstream& ifs) {
  std::streampos tmp = ifs.tellg();
  ifs.seekg(0, ifs.end);
  size_t totalLength = ifs.tellg();
  ifs.seekg(tmp);
  return (totalLength - ifs.tellg());
}
开发者ID:Kirill94,项目名称:lib-bio,代码行数:10,代码来源:tasks.cpp

示例2: processCentersWFN

/* ********************************************************************************************* */
void processCentersWFN(ifstream &ifil,const int nnu,string* &atlbl,solreal* &rr,solreal* &atch)
{
   alloc1DStringArray("atlbl",nnu,atlbl);
   alloc1DRealArray("rr",3*nnu,rr);
   alloc1DRealArray("atch",nnu,atch);
   string line;
   int fipos,fepos;
   size_t pos;
   //bool isspace=true;
   for (int i=0; i<nnu; i++) {
      fipos=ifil.tellg();
      getline(ifil,line);
      fepos=ifil.tellg();
      atlbl[i]=line.substr(0,12);
      while (atlbl[i][0]==' ') {atlbl[i].erase(0,1);}
      while (atlbl[i][atlbl[i].length()-1]==' ') {
         atlbl[i].erase(atlbl[i].length()-1);
      }
      pos=atlbl[i].find_first_of(' ');
      while (pos!=string::npos) {
         atlbl[i].erase(pos,1);
         pos=atlbl[i].find_first_of(' ');
      }
      line.erase(0,23);
      //sscanf(line.c_str(),"%g %g %g",&rr[3*i],&rr[3*i+1],&rr[3*i+2]);
      ifil.seekg(fipos+23);
      ifil >> rr[3*i] >> rr[3*i+1] >> rr[3*i+2];
      //cout << atlbl[i] << endl;
      //cout << "R[" << i << "]: " << rr[3*i] << " " << rr[3*i+1] << " " << rr[3*i+2] << endl;
      ifil.seekg(fipos+70);
      ifil >> atch[i];
      //cout << "Charge[" << i << "]: " << atch[i] << endl;
      ifil.seekg(fepos);
   }
}
开发者ID:jmsolano,项目名称:denstoolkit,代码行数:36,代码来源:iofuncts-wfn.cpp

示例3: read_bin_entry

    // Method to read an entry from a binary file
    // @param string filename - the name of the file which stores binary log entries
    // @param streampos entry_position - the position of the log entry to be read
    // @return BinaryLogEntry - the BinaryLogEntry struct containing all pertinent data
    //
    // Our binary log entry size is always the same. Some error checking
    // should be performed to ensure bytes received are expected and
    // and in correct order    
    // TODO current operation is dangerous and unreliable. A single missing byte will break all future log entry reading - use a delimination phrase between log entries, and scan accordingly
    BinaryLogEntry read_bin_entry(string filename, streampos entry_position) {
        Shakespeare::BinaryLogEntry log_entry;
        static ifstream inputBinary;
        inputBinary.open(filename.c_str(),ios_base::binary);
        streampos abs_position = entry_position*sizeof(log_entry);
        
        // store EOF conditions
        inputBinary.seekg(0,ios::end);
        size_t file_size;
        file_size = inputBinary.tellg();

        #ifdef CS1_DEBUG
            printf ("End: filesize:%d,entries:%ld\n", file_size, file_size / sizeof(log_entry) );
        #endif

        // seek back to beginning of file
        inputBinary.seekg(0,ios::beg);
        if (entry_position > 0) {// seek as required
            inputBinary.seekg(abs_position);
        }

        // take a reading if boundary conditions are met
        int cur_pos = inputBinary.tellg();
        if ( (unsigned)(file_size - cur_pos) >= sizeof(log_entry) ) {
            if (inputBinary) { // read and return log entry
                inputBinary.read( (char*)&log_entry, sizeof(log_entry) );
            }
        }

        // close and return
        inputBinary.close();
        return log_entry;
    }
开发者ID:julianlai777,项目名称:space-lib,代码行数:42,代码来源:shakespeare.cpp

示例4: GetFileSize

size_t CommonTools::GetFileSize(ifstream &fin)
{
    streampos loc = fin.tellg();
    fin.seekg(0, fin.end);
    size_t size = fin.tellg();
    fin.seekg(loc);
    return size;
}
开发者ID:BLin409,项目名称:Password,代码行数:8,代码来源:CommonTools.cpp

示例5: FileLength

size_t CommonFunction::FileLength(ifstream &file)
{
    streampos current_pos = file.tellg();
    file.seekg(0, ios::end);
    size_t len = file.tellg();
    file.seekg(current_pos);
    return len;
}
开发者ID:ljianhui,项目名称:HttpServer,代码行数:8,代码来源:commonfunction.cpp

示例6: get_file_size

/**
 * Returns the size of the given file.
 */
int get_file_size(ifstream &ifs)
{
	long begin, end;
	begin = ifs.tellg();
	ifs.seekg(0, ios::end);
	end = ifs.tellg();
	ifs.seekg(ios::beg);
	return end - begin;
}
开发者ID:orensam,项目名称:os_ex6,代码行数:12,代码来源:clftp.cpp

示例7: get_length

ifstream::pos_type get_length(ifstream &file)
/* Note that this function requires a binary file. */
{
	auto current_position = file.tellg();
	file.seekg(0, file.end);
	auto file_length = file.tellg();
	file.seekg(current_position);
	return file_length;
}
开发者ID:cout-hello-world,项目名称:otp,代码行数:9,代码来源:otp.cpp

示例8: GetFileLength

long GetFileLength(ifstream &ifs)
{
    long tmppos;
    long respos;
    tmppos = ifs.tellg();
    ifs.seekg(0, ios::end);
    respos = ifs.tellg();
    ifs.seekg(tmppos, ios::beg);
    return respos;
}
开发者ID:Redumbrella,项目名称:BookManager,代码行数:10,代码来源:myfun.cpp

示例9: getFileLength

unsigned long getFileLength(ifstream& file)
{  if(!file.good()) return 0;

    unsigned long pos=file.tellg();
    file.seekg(0,ios::end);
    unsigned long len = file.tellg();
    file.seekg(ios::beg);

    return len;
}
开发者ID:CarloNicolini,项目名称:glsl-sandbox,代码行数:10,代码来源:GLSL.cpp

示例10: size_of_stream

int size_of_stream(ifstream& f){
    /* Save the current position. */
    long save_pos = f.tellg( );
    /* Jump to the end of the file. */
    f.seekg(0, ios::end );
    /* Get the end position. */
    long size_of_file = f.tellg( );
    /* Jump back to the original position. */
    f.seekg( save_pos, ios::beg );
    return( size_of_file );
};
开发者ID:superkulpa,项目名称:phx-cnc-ui,代码行数:11,代码来源:iniFile.cpp

示例11: _getFileLength

unsigned long CShaderMngr::_getFileLength(ifstream &inFile) const
{
	if(!inFile.good()) return 0;
    
    streamoff pos = inFile.tellg();
    inFile.seekg(0,ios::end);
    streamoff len = inFile.tellg();
    inFile.seekg(pos);
    
    return static_cast<unsigned long>(len);
}
开发者ID:Gebhard-Stopper,项目名称:FlowIllustrator,代码行数:11,代码来源:ShaderMngr.cpp

示例12: filesize

long filesize(ifstream& f)
{
    long current = f.tellg();
    f.seekg(0, ios::beg);
    long beg = f.tellg();
    f.seekg(0, ios::end);
    long end = f.tellg();
    f.seekg(current, ios::beg);

    return end-beg;
}
开发者ID:Sudoka,项目名称:master-project,代码行数:11,代码来源:main.cpp

示例13: fileLength

unsigned long long fileLength(ifstream & file_stream)
{
    unsigned long long old_position = (unsigned long long) file_stream.tellg();

    file_stream.seekg(0, ios::end);
    unsigned long long length = (unsigned long long) file_stream.tellg();

    file_stream.seekg(old_position);

    return length;
}
开发者ID:RWTHmediTEC,项目名称:TRTK,代码行数:11,代码来源:Tools.cpp

示例14:

JSize
JGetFStreamLength
(
    ifstream& theStream
)
{
    const long savedMark = theStream.tellg();
    theStream.seekg(0, ios::end);
    const JSize fileLength = theStream.tellg();
    theStream.seekg(savedMark, ios::beg);
    return fileLength;
}
开发者ID:jafl,项目名称:jx_application_framework,代码行数:12,代码来源:jFStreamUtil.cpp

示例15: getFileSize

size_t dami::getFileSize(ifstream& file)
{
  size_t size = 0;
  if (file.is_open())
  {
    streamoff curpos = file.tellg();
    file.seekg(0, ios::end);
    size = file.tellg();
    file.seekg(curpos);
  }
  return size;
}
开发者ID:rusingineer,项目名称:eMule-scarangel,代码行数:12,代码来源:utils.cpp


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