The thing is, I have to read the file and write its data to another file. But the size might be so big (larger than 8 gb) so I read the files by chunks (1 mb), but I think the optimal size of the chunks can be calculated, so how do I do this? what tools should I use? Here's the code
const int BLOCK_SIZE = 1000000;
if(!(fin.open(QIODevice::ReadOnly)) == false &&
!(fout.open(QIODevice::WriteOnly)) == false) {\
long long m_file_size = fin.size();
QDataStream in(&fin);
QByteArray arrayOfBytes;
int counting = 0;
int check = 0;
long int bytesPerSecond = 0;
timer.start();
for(size_t i = 0; i <= m_file_size / BLOCK_SIZE; ++i) {
arrayOfBytes = fin.read(BLOCK_SIZE);
fout.write(arrayOfBytes);
bytesPerSecond +=BLOCK_SIZE;
if ((100 * ((timer.elapsed() + 50) / 100)) > 999 && (100 * ((timer.elapsed() + 50) / 100)) % 1000 == 0 && check != (100 * ((timer.elapsed() + 50) / 100)))
{
counting++;
check = (100 * ((timer.elapsed() + 50) / 100));//(10 * ((timer.elapsed() + 5) / 10));
bytesPerSecond = 0;
}
}
fin.close();
fout.close();
}
else{
qDebug()<<"Failed to open";
}
}