部分代码:
class ChunkInfo{
public:
char *buffer_address;//内存块的地址
long realsize;//内存块的大小
ChunkInfo(){}
ChunkInfo(char *buffer,long size)
{
this->realsize = size;
this->buffer_address = buffer;
}
};
list<ChunkInfo> CHUNK_INFO_LIST;
ifstream in;
in.open(inpath.c_str(),ios::in|ios::binary|ios::ate);
ifstream::pos_type size = in.tellg();
in.seekg(0,ios::beg);//指针回到头部
//如果文件大小大于1.5GB就分块读取,每块设置大小1.5GB,并把信息构造在ChunkInfo中,然后保存在list里。
if(size>MAX_SIZE_BIT)
{
cout<<"A"<<endl;
while(in.good())
{
cout<<in.tellg()<<endl;
//第一次循环正常,到第二次的时候就在这出错了
char *chunk_buffer = new char[CHUNK];
in.read(chunk_buffer,CHUNK);
long real_size = (long)in.gcount();
ChunkInfo chunk(chunk_buffer,real_size);
CHUNK_INFO_LIST.push_back(chunk);
}
in.close();
}
Qyouu
POPMUISE
相关分类