X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=examples%2Fcapturewim.c;h=ecc6b83cbc42aa41d27b4897a4a187aac2990ff0;hb=dac0e9d1b28c8c59e6cd1f35dfe71e163dc73bb1;hp=f2719705689bc91ffb5d760cba62748431e071e5;hpb=c3a1bd96026fd5a1d43c5f6178f9f0165afdd098;p=wimlib diff --git a/examples/capturewim.c b/examples/capturewim.c index f2719705..ecc6b83c 100644 --- a/examples/capturewim.c +++ b/examples/capturewim.c @@ -1,5 +1,8 @@ /* * capturewim.c - A program to capture a directory tree into a WIM file. + * + * The author dedicates this file to the public domain. + * You can do whatever you want with this file. */ #include @@ -8,9 +11,9 @@ #define TO_PERCENT(numerator, denominator) \ ((float)(((denominator) == 0) ? 0 : ((numerator) * 100 / (float)(denominator)))) -static int +static enum wimlib_progress_status write_progress(enum wimlib_progress_msg msg, - const union wimlib_progress_info *info) + union wimlib_progress_info *info, void *progctx) { switch (msg) { case WIMLIB_PROGRESS_MSG_WRITE_STREAMS: @@ -21,7 +24,7 @@ write_progress(enum wimlib_progress_msg msg, default: break; } - return 0; + return WIMLIB_PROGRESS_STATUS_CONTINUE; } int main(int argc, char **argv) @@ -45,14 +48,16 @@ int main(int argc, char **argv) if (ret != 0) /* Always should check the error codes. */ goto out; + /* Register our progress function. */ + wimlib_register_progress_function(wim, write_progress, NULL); + /* Add the directory tree to the WIMStruct as an image. */ ret = wimlib_add_image(wim, /* WIMStruct to which to add the image */ srcdir, /* Directory from which to add the image */ NULL, /* Name to give the image (NULL means none) */ NULL, /* Capture configuration structure (NULL means none) */ - 0, /* WIMLIB_ADD_FLAG_* flags (0 means all defaults) */ - NULL); /* Progress function (NULL means none) */ + 0); /* WIMLIB_ADD_FLAG_* flags (0 means all defaults) */ if (ret != 0) goto out; @@ -62,8 +67,7 @@ int main(int argc, char **argv) wimpath, /* Path to write the WIM to */ WIMLIB_ALL_IMAGES, /* Image(s) in the WIM to write */ 0, /* WIMLIB_WRITE_FLAG_* flags (0 means all defaults) */ - 0, /* Number of compressor threads (0 means default) */ - write_progress); /* Progress function */ + 0); /* Number of compressor threads (0 means default) */ out: /* Free the WIMStruct. Has no effect if the pointer to it is NULL. */