1 #ifndef _WIMLIB_PROGRESS_H
2 #define _WIMLIB_PROGRESS_H
5 #include "wimlib/types.h"
7 /* If specified, call the user-provided progress function and check its result.
10 call_progress(wimlib_progress_func_t progfunc,
11 enum wimlib_progress_msg msg,
12 union wimlib_progress_info *info,
16 enum wimlib_progress_status status;
18 status = (*progfunc)(msg, info, progctx);
21 case WIMLIB_PROGRESS_STATUS_CONTINUE:
23 case WIMLIB_PROGRESS_STATUS_ABORT:
24 return WIMLIB_ERR_ABORTED_BY_PROGRESS;
26 return WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS;
33 report_error(wimlib_progress_func_t progfunc,
34 void *progctx, int error_code, const tchar *path);
36 /* Rate-limiting of byte-count based progress messages: update *next_progress_p
37 * to the value that completed_bytes needs to reach before the next progress
38 * message will be sent. */
40 set_next_progress(u64 completed_bytes, u64 total_bytes, u64 *next_progress_p)
42 if (*next_progress_p < total_bytes) {
44 * Send the next message as soon as:
45 * - another 1/128 of the total has been processed;
46 * - OR another 5000000 bytes have been processed;
47 * - OR all bytes have been processed.
49 *next_progress_p = min(min(completed_bytes + total_bytes / 128,
50 completed_bytes + 5000000),
53 /* Last message has been sent. */
54 *next_progress_p = ~0;
58 #endif /* _WIMLIB_PROGRESS_H */