- if (!tstrcasecmp(optarg, T("maximum")) || !tstrcasecmp(optarg, T("lzx")))
- return WIMLIB_COMPRESSION_TYPE_LZX;
- else if (!tstrcasecmp(optarg, T("fast")) || !tstrcasecmp(optarg, T("xpress")))
- return WIMLIB_COMPRESSION_TYPE_XPRESS;
- else if (!tstrcasecmp(optarg, T("recovery")) || !tstrcasecmp(optarg, T("lzms")))
- return WIMLIB_COMPRESSION_TYPE_LZMS;
- else if (!tstrcasecmp(optarg, T("none")))
- return WIMLIB_COMPRESSION_TYPE_NONE;
- else {
- imagex_error(T("Invalid compression type \"%"TS"\"! Must be "
- "\"maximum\", \"fast\", or \"none\"."), optarg);
+ int ctype;
+ unsigned int compression_level = 0;
+ tchar *plevel;
+
+ plevel = tstrchr(optarg, T(':'));
+ if (plevel) {
+ tchar *ptmp;
+ unsigned long ultmp;
+
+ *plevel++ = T('\0');
+ ultmp = tstrtoul(plevel, &ptmp, 10);
+ if (ultmp >= UINT_MAX || ultmp == 0 || *ptmp || ptmp == plevel) {
+ imagex_error(T("Compression level must be a positive integer! "
+ "e.g. --compress=lzx:80"));
+ return WIMLIB_COMPRESSION_TYPE_INVALID;
+ }
+ compression_level = ultmp;
+ }
+
+ if (!tstrcasecmp(optarg, T("maximum")) ||
+ !tstrcasecmp(optarg, T("lzx")) ||
+ !tstrcasecmp(optarg, T("max"))) {
+ ctype = WIMLIB_COMPRESSION_TYPE_LZX;
+ } else if (!tstrcasecmp(optarg, T("fast")) || !tstrcasecmp(optarg, T("xpress"))) {
+ ctype = WIMLIB_COMPRESSION_TYPE_XPRESS;
+ } else if (!tstrcasecmp(optarg, T("recovery"))) {
+ if (!solid) {
+ tfprintf(stderr,
+T(
+"Warning: use of '--compress=recovery' is discouraged because it behaves\n"
+" differently from DISM. Instead, you typically want to use '--solid' to\n"
+" create a solid LZMS-compressed WIM or \"ESD file\", similar to DISM's\n"
+" /compress:recovery. But if you really want *non-solid* LZMS compression,\n"
+" then you may suppress this warning by specifying '--compress=lzms' instead\n"
+" of '--compress=recovery'.\n"));
+ }
+ ctype = WIMLIB_COMPRESSION_TYPE_LZMS;
+ } else if (!tstrcasecmp(optarg, T("lzms"))) {
+ ctype = WIMLIB_COMPRESSION_TYPE_LZMS;
+ } else if (!tstrcasecmp(optarg, T("none"))) {
+ ctype = WIMLIB_COMPRESSION_TYPE_NONE;
+ } else {
+ imagex_error(T("Invalid compression type \"%"TS"\"!"), optarg);
+ print_available_compression_types(stderr);