bool can_seek;
int ret;
- can_seek = !(lseek(ctx->wim->in_fd.fd, 0, SEEK_CUR) == (off_t)-1 &&
- errno == ESPIPE);
+ can_seek = (lseek(ctx->wim->in_fd.fd, 0, SEEK_CUR) != -1);
list_for_each_entry(lte, &ctx->stream_list, extraction_list) {
ret = extract_stream_instances(lte, ctx, can_seek);
if (ret)
* output. In that case, "root" should be a single file, not a
* directory tree. (If not, extract_dentry_to_stdout() will
* return an error.) */
- if (extract_flags & WIMLIB_EXTRACT_FLAG_TO_STDOUT &&
- !(extract_flags & WIMLIB_EXTRACT_FLAG_FROM_PIPE)) {
+ if (extract_flags & WIMLIB_EXTRACT_FLAG_TO_STDOUT) {
ret = extract_dentry_to_stdout(root);
goto out_teardown_stream_list;
}
return ret;
/* Make sure there are no streams in the WIM that have not been
- * checksummed yet. Needed at least because 'unhashed_list' aliases
- * 'extraction_list' in `struct wim_lookup_table_entry'. */
+ * checksummed yet. */
ret = wim_checksum_unhashed_streams(wim);
if (ret)
return ret;
extract_flags |= WIMLIB_EXTRACT_FLAG_MULTI_IMAGE;
-#ifdef WITH_NTFS_3G
if (extract_flags & WIMLIB_EXTRACT_FLAG_NTFS) {
ERROR("Cannot extract multiple images in NTFS extraction mode.");
return WIMLIB_ERR_INVALID_PARAM;
}
-#endif
if (tstat(target, &stbuf)) {
if (errno == ENOENT) {
/* Get image index (this may use the XML data that was just read to
* resolve an image name). */
- image = wimlib_resolve_image(pwm, image_num_or_name);
- if (image == WIMLIB_NO_IMAGE) {
- ERROR("\"%"TS"\" is not a valid image in the pipable WIM!",
- image_num_or_name);
- ret = WIMLIB_ERR_INVALID_IMAGE;
- goto out_wimlib_free;
- } else if (image == WIMLIB_ALL_IMAGES) {
- ERROR("Applying all images from a pipe is not supported.");
- ret = WIMLIB_ERR_INVALID_IMAGE;
- goto out_wimlib_free;
+ if (image_num_or_name) {
+ image = wimlib_resolve_image(pwm, image_num_or_name);
+ if (image == WIMLIB_NO_IMAGE) {
+ ERROR("\"%"TS"\" is not a valid image in the pipable WIM!",
+ image_num_or_name);
+ ret = WIMLIB_ERR_INVALID_IMAGE;
+ goto out_wimlib_free;
+ } else if (image == WIMLIB_ALL_IMAGES) {
+ ERROR("Applying all images from a pipe is not supported.");
+ ret = WIMLIB_ERR_INVALID_IMAGE;
+ goto out_wimlib_free;
+ }
+ } else {
+ if (pwm->hdr.image_count != 1) {
+ ERROR("No image was specified, but the pipable WIM "
+ "did not contain exactly 1 image");
+ ret = WIMLIB_ERR_INVALID_IMAGE;
+ goto out_wimlib_free;
+ }
+ image = 1;
}
/* Load the needed metadata resource. */