void ClassWrite::fnWriteFile(FILE *fp, int nFillWith)
{
unsigned long value = 0;
int iProgressCounter = 0;
long long llSizeRead = 0;
unsigned long SizetoRead =0;
long long SizeRead = 0;
llSizeRead = filename.size();
unsigned char *pBuffer = NULL;
unsigned long dwBufferValue = 4*1024*1024;
pBuffer = (unsigned char *)calloc(dwBufferValue,sizeof(unsigned char));
if(pBuffer == NULL)
return;
strMessage = "WritingFile " + m_FileName;
emit ProgressMaximumValue(100);
qApp->processEvents();
while(llSizeRead>0)
{
if(bStopFlag)
break;
if(llSizeRead>dwBufferValue)
{
SizetoRead = dwBufferValue;
value = ((SizetoRead/llSizeRead)*100);
if(iProgressCounter == 0 || iProgressCounter == 100)
{
emit SetProgressValue(strMessage,value);
qApp->processEvents();
memset(pBuffer,nFillWith,SizetoRead);
fseek(fp, 0+SizeRead, SEEK_CUR);
fwrite((void*)pBuffer,SizetoRead,1,fp);
llSizeRead-=SizetoRead;
SizeRead = SizetoRead;
iProgressCounter = 0;
}
iProgressCounter++;
}
else
{
SizetoRead = llSizeRead;
value = ((SizetoRead/llSizeRead)*100);
if(iProgressCounter == 0 || iProgressCounter == 100)
{
emit SetProgressValue(strMessage,value);
qApp->processEvents();
memset(pBuffer,nFillWith,SizetoRead);
fseek(fp, 0+SizeRead, SEEK_CUR);
fwrite((void*)pBuffer,SizetoRead,1,fp);
llSizeRead-=SizetoRead;
SizeRead = SizetoRead;
iProgressCounter = 0;
}
iProgressCounter++;
}
}
fflush(fp);
if(pBuffer)
{
free(pBuffer);
pBuffer = NULL;
}
}
void ClassWrite::fnWriteFile(FILE *fp, int nFillWith)
{
unsigned long value = 0;
int iProgressCounter = 0;
long long llSizeRead = 0;
unsigned long SizetoRead =0;
long long SizeRead = 0;
QFileInfo filename(m_FileName);
llSizeRead = filename.size();
QString strMessage = "";
unsigned char *pBuffer = NULL;
unsigned long dwBufferValue = 4*1024*1024;
pBuffer = (unsigned char *)calloc(dwBufferValue,sizeof(unsigned char));
if(pBuffer == NULL)
return;
strMessage = "WritingFile " + m_FileName;
emit ProgressMaximumValue(100);
qApp->processEvents();
while(llSizeRead>0)
{
if(bStopFlag)
break;
if(llSizeRead>dwBufferValue)
{
SizetoRead = dwBufferValue;
value = ((SizetoRead/llSizeRead)*100);
if(iProgressCounter == 0 || iProgressCounter == 100)
{
emit SetProgressValue(strMessage,value);
qApp->processEvents();
memset(pBuffer,nFillWith,SizetoRead);
fseek(fp, 0+SizeRead, SEEK_CUR);
fwrite((void*)pBuffer,SizetoRead,1,fp);
llSizeRead-=SizetoRead;
SizeRead = SizetoRead;
iProgressCounter = 0;
}
iProgressCounter++;
}
else
{
SizetoRead = llSizeRead;
value = ((SizetoRead/llSizeRead)*100);
if(iProgressCounter == 0 || iProgressCounter == 100)
{
emit SetProgressValue(strMessage,value);
qApp->processEvents();
memset(pBuffer,nFillWith,SizetoRead);
fseek(fp, 0+SizeRead, SEEK_CUR);
fwrite((void*)pBuffer,SizetoRead,1,fp);
llSizeRead-=SizetoRead;
SizeRead = SizetoRead;
iProgressCounter = 0;
}
iProgressCounter++;
}
}
fflush(fp);
if(pBuffer)
{
free(pBuffer);
pBuffer = NULL;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks