To make a long story short here is the situation I'm in right now:
I have one thread downloading a file from the web to a local file.
I need the other thread to get the local file's current size AS its downloading.
So, what would you guys recommend to do this? Here's what I've gone through already:
long begin,end,size;
ifstream myfile ("C:\\HOCR\\MalwareBytesSetup.exe",);
begin = myfile.tellg();
myfile.seekg (0, ios::end);
end = myfile.tellg();
myfile.close();
size = end-begin;
This won't work becuase the file is open by the 'downloading' thread.
struct stat fileStat;
stat( "C:\\HOCR\\MalwareBytesSetup.exe", &fileStat );
int filesize=fileStat.st_size;
This WILL get the current size, but it isn't updated as the file downloads. Although, it does update if you refresh the c:\HOCR folder in explorer. (Maybe that can be done programmatically?)
Thanks for your help in advanced!