Thk u very much.
I try to answer what you ask me.
1.why I need to write so large file?
I have another 55G file,and I need extract part of its data to save the new file(its size must be less than 55G,but I don't know what size of it precisely in advance,maybe 53G,54G,etc),Maybe you ask me why you need so large file,you can split it into many small files,I think,55Gb file,in petroleum domain,is not large file.
2.In order to speed up the speed of extracting data and writing data(to create the 55Gb file),I use "file mapping object" in windows,which is involved in functions,as you know,such as CreateFileMapping and MapViewOfFile.
I open the 55G file and create map object of it with the following code:
hFile = CreateFile( fileName.utf16() , GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if ( hFile == INVALID_HANDLE_VALUE )
{
QMessageBox::warning( 0, "aaa1", QString::fromLocal8Bit("reading data fail 1") );
return false;
}
hMapFile= CreateFileMapping(hFile,NULL, PAGE_READONLY,(DWORD)0,(DWORD)0,NULL);
if ( hMapFile==NULL )
{
QMessageBox::warning( 0, "aaa2", QString::fromLocal8Bit("reading data fail 2") );
return false;
}
I create the object file with following code:
qwFileSize=54G;//define the size of writing file,its size is less than 55G,here I define it 54G;
QString Objfilename="h:\\tmp.sgy";//here H disk has 487G free space.
ObjhFile = CreateFile( Objfilename.utf16() , GENERIC_WRITE | GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
if (ObjhFile == INVALID_HANDLE_VALUE )
{
QMessageBox::warning(0,"",QString::number(GetLastError()));
QMessageBox::warning( 0, "wCreateFile", QString::fromLocal8Bit("writing data fail 1") );
return false;
}
ObjhMapFile= CreateFileMapping(ObjhFile,NULL, PAGE_READWRITE,(DWORD)(qwFileSize>>32), (DWORD)(qwFileSize&0xFFFFFFFF),NULL);
if ( objhMapFile==NULL )
{
QMessageBox::warning(0,"wCreateFileMapping",QString::number(GetLastError()));//Here occur error: 112,means that the disk has not enough space.
QMessageBox::warning( 0, "wCreateFileMapping", QString::fromLocal8Bit("writing data fail 2") );
return false;
}
the H disk has more than 55G(487G) free space,the error still exist.I think that,the function CreateFileMapping does not use the disk the object file will be save to,but use the default disk(maybe C:).
if I want to create a large file,how to deal with it when c disk has not enough free space?
3.I want to extract part of data from a large file,how to accelerate the process of it except "file mapping".Some one tell me create a file index,I do not know how to realize it.
4.Thk u a lot for help me.