When trying to copy a file size more than 4.30 GB LPPROGRESS_ROUTINE lpProgressRoutine callback function is not updating the current bytes after "4293918720" bytes it is resetting to 0 and at the end of file copy it updates the current bytes as "947912771" which is wrong. actual file size is "5242880067" bytes. Once the copy is completed in system it shows correct file size.
Please tell me where can it go wrong.
code snippet
typedef struct CopyItemData {
FileProgressCallback callback;
void* data;
uint64_t current;
uint64_t total;
Error result;
BOOL cancel;
int64_t tmpCurrent;
int64_t tmpTotal;
} CopyItemData;
int CopyFileInternal(const nstring& srcPath, const nstring& dstPath, FileProgressCallback callback, void* data){
CopyItemData cid;
cid.callback = callback;
cid.data = data;
cid.current = 0;
cid.total = 0;
cid.result = SyncOK;
cid.cancel = FALSE;
CopyFileEx((prefix + srcPath).c_str(), (prefix + dstPath).c_str(), CopyFileEx_progress, &cid, &cid.cancel, 0));
}
static DWORD WINAPI CopyFileEx_progress(
LARGE_INTEGER TotalFileSize,
LARGE_INTEGER TotalBytesTransferred,
LARGE_INTEGER StreamSize,
LARGE_INTEGER StreamBytesTransferred,
DWORD dwStreamNumber,
DWORD dwCallbackReason,
HANDLE hSourceFile,
HANDLE hDestinationFile,
LPVOID lpData) {
CopyItemData* pcid = reinterpret_cast<CopyItemData*>(lpData);
if (pcid == nullptr)
return PROGRESS_CANCEL;
pcid->current = TotalBytesTransferred.QuadPart;
pcid->total = TotalFileSize.QuadPart;
pcid->result = pcid->callback(pcid->data, pcid->current, pcid->total);
if (pcid->result != 0)
return PROGRESS_CANCEL;
return PROGRESS_CONTINUE;
}
Thanks in advance.