本文整理汇总了C++中Progress::GetCurrentDone方法的典型用法代码示例。如果您正苦于以下问题:C++ Progress::GetCurrentDone方法的具体用法?C++ Progress::GetCurrentDone怎么用?C++ Progress::GetCurrentDone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Progress
的用法示例。
在下文中一共展示了Progress::GetCurrentDone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HEXDump_FindCallBack
static int HEXDump_FindCallBack(FindData &fd, HDFDCB_Data *pUserParam)
{
if (!fd.fileMatched)
return 0;
int argc(pUserParam->argc);
TCHAR **argv(pUserParam->argv);
BinaryFind &bf(pUserParam->bf);
FILE *fp = NULL;
_tfopen_s(&fp, fd.fullPath.c_str(), _T("rb"));
if (fp != NULL)
{
int nMatches(0);
bf.SetFindBuffer();
_tprintf(_T("%s\n"), fd.fullPath.c_str());
pUserParam->nFiles++;
Progress prog;
const TCHAR *argStr = FindArgValue(argc, argv, _T("-o="));
if (argStr != NULL) {
long long offset(StringUtils::getLLfromStr(argStr));
_fseeki64(fp, offset, offset >= 0 ? SEEK_SET : SEEK_END);
}
long long fileOffset(_ftelli64(fp));
long long sizeToRead(fd.GetFileSize());
const long long fileSize(sizeToRead);
argStr = FindArgValue(argc, argv, _T("-s="));
if (argStr != NULL) {
long long szRead = StringUtils::getLLfromStr(argStr);
if (fileOffset + szRead > sizeToRead)
sizeToRead = sizeToRead - fileOffset;
else
sizeToRead = szRead;
}
size_t findDumpSize(0), findDumpOffset(-16);
if (bf.HasFindPattern()) {
argStr = FindArgValue(argc, argv, _T("-d"));
if (argStr != NULL) {
if (*argStr == '=') {
findDumpSize = StringUtils::getLLfromStr(argStr + 1);
STR_SKIP_TILL_CHAR(argStr, ';');
if (*argStr)
findDumpOffset = StringUtils::getLLfromStr(argStr + 1);
}
if (findDumpSize <= 0)
findDumpSize = 48;
}
}
prog.SetTask(sizeToRead);
BinaryData buffer(NULL, 4 * 1024 * 1024);
while (sizeToRead > 0)
{
buffer.ReadFromFile(fp);
if (buffer.DataSize() <= 0)
break;
sizeToRead -= buffer.DataSize();
if (bf.HasFindPattern()) {
bf.SetFindBuffer(buffer);
while (true)
{
long long findPos = bf.FindNext();
if (findPos >= 0) {
_tprintf(_T("%08llX=-%08llX\n"), fileOffset + findPos, fileSize - (fileOffset + findPos));
if (findDumpSize > 0) {
const long long curPos(_ftelli64(fp));
long long newPos(fileOffset + findPos + findDumpOffset);
if (newPos < 0)
newPos = 0;
newPos &= ~0xf;
BinaryData bd(NULL, findDumpSize);
bd.ReadFromFile(fp, 0, newPos);
HexDump(bd, newPos);
_fseeki64(fp, curPos, SEEK_SET);
}
++nMatches;
}
else break;
}
}
else
fileOffset = HexDump(buffer, fileOffset);
if (prog.UpdateProgress(prog.GetCurrentDone() + buffer.DataSize()))
_tprintf(_T("\r%02.02f%%\r"), prog.GetCurrentPercentageDone());
}
_tprintf(_T("\r \r"));
fclose(fp);
if (nMatches > 0) {
pUserParam->nFound++;
if (nMatches > pUserParam->nMaxMatchPerFile)
pUserParam->nMaxMatchPerFile = nMatches;
if (nMatches > 1)
_tprintf(_T("%d matches\n"), nMatches);
}
}
return 0;
}