- ret = wimlib_set_output_dir(w, dir);
- if (ret != 0)
- goto done;
- wimlib_set_verbose(w, verbose);
- wimlib_set_link_type(w, link_type);
- ret = wimlib_extract_image(w, image);
-done:
+
+#ifdef WITH_NTFS_3G
+ struct stat stbuf;
+
+ ret = stat(dir, &stbuf);
+ if (ret == 0) {
+ if (S_ISBLK(stbuf.st_mode) || S_ISREG(stbuf.st_mode)) {
+ const char *ntfs_device = dir;
+ printf("Applying image %d of `%s' to NTFS filesystem on `%s'\n",
+ image, wimfile, ntfs_device);
+ ret = wimlib_apply_image_to_ntfs_volume(w, image,
+ ntfs_device,
+ extract_flags);
+ goto out;
+ }
+ } else {
+ if (errno != -ENOENT)
+ imagex_error_with_errno("Failed to stat `%s'", dir);
+ }
+#endif
+
+ ret = wimlib_extract_image(w, image, dir, extract_flags);
+out: