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


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

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


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

示例1: fileLength

uint fileLength(std::fstream & file){
    std::streamoff oldPos = file.tellg();
    file.seekg(0, std::ios::end);
    std::streamoff length = file.tellg();
    file.seekg(oldPos);
    return (uint)length;
}
开发者ID:dongxu-cug,项目名称:gimli,代码行数:7,代码来源:gimli.cpp

示例2: readFolder

Folder::Ptr Folder::readFolder(std::fstream &file, BSAULong fileNamesLength,
                               BSAULong &endPos)
{
  Folder::Ptr result(new Folder());
  result->m_NameHash = readType<BSAHash>(file);
  result->m_FileCount = readType<unsigned long>(file);
  result->m_Offset = readType<unsigned long>(file);
  std::streamoff pos = file.tellg();

  file.seekg(result->m_Offset - fileNamesLength, fstream::beg);

  result->m_Name = readBString(file);

  for (unsigned long i = 0UL; i < result->m_FileCount; ++i) {
    result->m_Files.push_back(File::Ptr(new File(file, result.get())));
  }

  if (static_cast<unsigned long>(file.tellg()) > endPos) {
    endPos = static_cast<BSAULong>(file.tellg());
  }

  file.seekg(pos);

  return result;
}
开发者ID:TanninOne,项目名称:modorganizer-bsatk,代码行数:25,代码来源:bsafolder.cpp

示例3: fileSize

	unsigned int fileSize(std::fstream& file)
	{
		unsigned int oldpos = file.tellg();
		file.seekg(0, std::ios::end);
		unsigned int filesize = file.tellg();
		file.seekg(oldpos, std::ios::beg);
		return filesize;
	}
开发者ID:CBaiz,项目名称:PeLib,代码行数:8,代码来源:PeLibAux.cpp

示例4: rawOpen

bool SnappyFile::rawOpen(const std::string &filename, File::Mode mode)
{
    std::ios_base::openmode fmode = std::fstream::binary;
    if (mode == File::Write) {
        fmode |= (std::fstream::out | std::fstream::trunc);
        createCache(SNAPPY_CHUNK_SIZE);
    } else if (mode == File::Read) {
        fmode |= std::fstream::in;
    }

    m_stream.open(filename.c_str(), fmode);

    //read in the initial buffer if we're reading
    if (m_stream.is_open() && mode == File::Read) {
        m_stream.seekg(0, std::ios::end);
        m_endPos = m_stream.tellg();
        m_stream.seekg(0, std::ios::beg);

        // read the snappy file identifier
        unsigned char byte1, byte2;
        m_stream >> byte1;
        m_stream >> byte2;
        assert(byte1 == SNAPPY_BYTE1 && byte2 == SNAPPY_BYTE2);

        flushReadCache();
    } else if (m_stream.is_open() && mode == File::Write) {
开发者ID:Hsaniva,项目名称:apitrace,代码行数:26,代码来源:trace_file_snappy.cpp

示例5: GetLength

size_t File::GetLength(std::fstream &file)
{
	file.seekg(0, file.end);
	size_t len = file.tellg();
	file.seekg(0, file.beg);
	
	return len;
}
开发者ID:AmarSaggu,项目名称:ORAM,代码行数:8,代码来源:File.cpp

示例6: ReadOtherInfoFromFile

UINT64 TargetPhrase::ReadOtherInfoFromFile(UINT64 filePos, std::fstream &fileTPColl)
{
  CHECK(filePos == (UINT64)fileTPColl.tellg());

  UINT64 memUsed = 0;
  fileTPColl.read((char*) &m_filePos, sizeof(UINT64));
  memUsed += sizeof(UINT64);
  CHECK(m_filePos != 0);

  memUsed += ReadAlignFromFile(fileTPColl);
  CHECK((memUsed + filePos) == (UINT64)fileTPColl.tellg());

  memUsed += ReadScoresFromFile(fileTPColl);
  CHECK((memUsed + filePos) == (UINT64)fileTPColl.tellg());

  return memUsed;
}
开发者ID:ILucifer,项目名称:mosesdecoder,代码行数:17,代码来源:TargetPhrase.cpp

示例7: Read

bool OsFileImpl::Read( void* Data, size_t Size )
{
    if( !IsValid() )
    {
        return false;
    }
    mFile.read( ( char* )Data, Size );
    mPosition = mFile.tellg();
    return IsValid();
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:10,代码来源:osfile.cpp

示例8: GetContents

String File::GetContents(std::fstream & fileStream)
{
	assert(fileStream.is_open());
	fileStream.seekg( 0, std::ios::beg);
	int start  = (int) fileStream.tellg();
	fileStream.seekg( 0, std::ios::end );
	int fileSize = (int) fileStream.tellg();
	// Empty file?
	if (fileSize == 0)
		return String();
	assert(fileSize);
	char * data = new char [fileSize+2];
	memset(data, 0, fileSize+1);
	fileStream.seekg( 0, std::ios::beg);
	fileStream.read((char*) data, fileSize);
	String strData(data);
	delete[] data;
	return strData;
}
开发者ID:erenik,项目名称:engine,代码行数:19,代码来源:File.cpp

示例9: copyUntilEOFInString

/*!
 * Copies entire file into a char array
 * @param[in]   str     file stream to be copied; file nneds already to be opened
 * @param[out]  buffer  char array containing entire array
 * @param[out]  length  number of elements which hvae benn copied
 */
void copyUntilEOFInString( std::fstream &str, char*& buffer, int &length) {

    std::fstream::pos_type   position_insert, position_eof ;

    position_insert = str.tellg() ;

    str.seekg(0, str.end);
    position_eof = str.tellg();

    length = position_eof - position_insert ;
    buffer = new char[length] ;

    str.seekg(position_insert);
    str.read(buffer,length ) ;

    str.seekg(position_insert);

    return;
};
开发者ID:optimad,项目名称:bitpit,代码行数:25,代码来源:GenericIO.cpp

示例10: readBlockFromFile

Block readBlockFromFile(std::fstream& f) {
  Block b {};
  BlockOffset off = f.tellg();
  f.read(reinterpret_cast<char *>(&b.data), sizeof(b.data));
  for(auto& o : b.offsets) {
      f.read(reinterpret_cast<char *>(&o), sizeof(o));
  }
  f.seekg(off, f.beg);
  return b;  
}
开发者ID:UIKit0,项目名称:superindexer,代码行数:10,代码来源:superindexer.cpp

示例11: Write

bool OsFileImpl::Write( void const* Src, size_t Size )
{
    if( !IsValid() )
    {
        return false;
    }
    mSize += Size;
    mFile.write( ( char const* )Src, Size );
    mPosition = mFile.tellg();
    return IsValid();
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:11,代码来源:osfile.cpp

示例12:

	SeekableFileStream(const char *name) {
		_fileStream = new std::fstream();
		_fileStream->open(name, std::fstream::in | std::fstream::binary);
		if (_fileStream->fail()) {
			_length = -1;
		} else {
			_fileStream->seekg(0, std::ios_base::end);
			_length = _fileStream->tellg();
			_fileStream->seekg(0, std::ios_base::beg);
		}
	}
开发者ID:somaen,项目名称:grime-tools-mac,代码行数:11,代码来源:filestream.cpp

示例13: loadAt

void IndexDataStructure::loadAt(std::fstream & _input_file, std::streampos _position)
{
    // remember the read file position
    std::streampos r_pos = _input_file.tellg();

    // go to asked read position
    _input_file.seekg(_position);
    readToNext(_input_file);

    // restore original read position
    _input_file.seekg(r_pos);
}
开发者ID:campisano,项目名称:b_plus_tree,代码行数:12,代码来源:IndexDataStructure.cpp

示例14: ChunkWrite

void MeshFileLoader::ChunkWrite( std::fstream &filestr, char *src, unsigned size, unsigned chunksize )
{
    if (!size)
        return;

    int filesize = (int)filestr.tellg();
    int chunks = size / chunksize;
    for ( int i = 0; i < chunks; ++i )
    {
        filestr.write( src + i * chunksize, chunksize );
    }
    filestr.write( src + chunks * chunksize, size % chunksize );
}
开发者ID:Downstream,项目名称:ds_cinder,代码行数:13,代码来源:mesh_file_loader.cpp

示例15: readToNext

void IndexDataStructure::readToNext(std::fstream & _input_file)
{
    m_is_indexed = true;
    m_index_position = _input_file.tellg();

    _input_file.read((char *)(&m_count), sizeof(m_count));
    _input_file.read((char *)(m_keys), sizeof(m_keys[0]) * m_max_count);
    _input_file.read((char *)(m_addresses), sizeof(m_addresses[0]) * m_max_count);
    _input_file.read((char *)(&m_next_sibling_address), sizeof(m_next_sibling_address));

    // skip free block space
    _input_file.seekg(m_block_size - m_real_data_size, _input_file.cur);
}
开发者ID:campisano,项目名称:b_plus_tree,代码行数:13,代码来源:IndexDataStructure.cpp


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