ba62a9571f42b3dcc0884e490d033131d8f1e840
[wimlib] / examples / applywim.c
1 /*
2  * applywim.c - A simple program to extract all images from a WIM file to a
3  * directory.
4  */
5
6 #include <wimlib.h>
7 #include <stdio.h>
8
9 int main(int argc, char **argv)
10 {
11         int ret;
12         WIMStruct *wim;
13
14         if (argc != 3) {
15                 fprintf(stderr, "Usage: applywim WIM DIR\n");
16                 ret = 2;
17                 goto out;
18         }
19
20         /* Initialize the library. */
21         ret = wimlib_global_init(0);
22         if (ret)
23                 goto out;
24
25         /* Open the WIM file. */
26         ret = wimlib_open_wim(argv[1], 0, &wim, NULL);
27         if (ret)
28                 goto out_wimlib_global_cleanup;
29
30         /* Extract all the images. */
31         ret = wimlib_extract_image(wim, WIMLIB_ALL_IMAGES, argv[2], 0,
32                                    NULL, 0, NULL);
33
34         /* Free the WIM file */
35         wimlib_free(wim);
36
37 out_wimlib_global_cleanup:
38         /* Finalize the library */
39         wimlib_global_cleanup();
40 out:
41         return ret;
42 }