mirror of
https://github.com/fadden/nulib2.git
synced 2025-01-29 22:30:30 +00:00
Implemented "percentComplete" field in progress update.
This commit is contained in:
parent
b9c91715f2
commit
5c0f57cf71
@ -172,12 +172,36 @@ Nu_ProgressDataExpandPrep(NuArchive* pArchive, NuFunnel* pFunnel,
|
||||
return kNuErrNone;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute a completion percentage.
|
||||
*/
|
||||
static int
|
||||
Nu_ComputePercent(ulong total, ulong progress)
|
||||
{
|
||||
ulong perc;
|
||||
|
||||
if (!total)
|
||||
return 0;
|
||||
|
||||
if (total < 21474836) {
|
||||
perc = (progress * 100 + 50) / total;
|
||||
if (perc > 100)
|
||||
perc = 100;
|
||||
} else {
|
||||
perc = progress / (total / 100);
|
||||
if (perc > 100)
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
return (int) perc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send the initial progress message, before the output file is opened
|
||||
* (when extracting) or the input file is opened (when adding).
|
||||
*/
|
||||
NuError
|
||||
Nu_SendInitialProgress(NuArchive* pArchive, const NuProgressData* pProgress)
|
||||
Nu_SendInitialProgress(NuArchive* pArchive, NuProgressData* pProgress)
|
||||
{
|
||||
NuResult result;
|
||||
|
||||
@ -187,6 +211,9 @@ Nu_SendInitialProgress(NuArchive* pArchive, const NuProgressData* pProgress)
|
||||
if (pProgress->progressFunc == nil)
|
||||
return kNuErrNone;
|
||||
|
||||
pProgress->percentComplete = Nu_ComputePercent(
|
||||
pProgress->uncompressedLength, pProgress->uncompressedProgress);
|
||||
|
||||
result = (*pProgress->progressFunc)(pArchive, (NuProgressData*) pProgress);
|
||||
|
||||
if (result == kNuSkip)
|
||||
@ -703,7 +730,7 @@ Nu_StrawFree(NuArchive* pArchive, NuStraw* pStraw)
|
||||
|
||||
|
||||
/*
|
||||
* Set the Funnel's progress state.
|
||||
* Set the Straw's progress state.
|
||||
*/
|
||||
NuError
|
||||
Nu_StrawSetProgressState(NuStraw* pStraw, NuProgressState state)
|
||||
|
@ -615,8 +615,7 @@ NuError Nu_ProgressDataInit_Compress(NuArchive* pArchive,
|
||||
NuError Nu_ProgressDataInit_Expand(NuArchive* pArchive,
|
||||
NuProgressData* pProgressData, const NuRecord* pRecord,
|
||||
const char* newPathname, char newFssep, NuValue convertEOL);
|
||||
NuError Nu_SendInitialProgress(NuArchive* pArchive,
|
||||
const NuProgressData* pProgress);
|
||||
NuError Nu_SendInitialProgress(NuArchive* pArchive, NuProgressData* pProgress);
|
||||
|
||||
NuError Nu_FunnelNew(NuArchive* pArchive, NuDataSink* pDataSink,
|
||||
NuValue convertEOL, NuValue convertEOLTo, NuProgressData* pProgress,
|
||||
|
Loading…
x
Reference in New Issue
Block a user