]> wimlib.net Git - wimlib/blobdiff - src/extract.c
wimlib-imagex: Allow specifying LZMS compression
[wimlib] / src / extract.c
index 5939671716455dc0c0a3b0008db82da450050e59..9feb7a0e6a718d563a2fc3ca6c9d045ed170d849 100644 (file)
@@ -534,10 +534,10 @@ error:
  * This function operates slightly differently depending on whether @lte_spec is
  * NULL or not.  When @lte_spec is NULL, the behavior is to extract the default
  * file contents (unnamed stream), and, if named data streams are supported in
- * the extract mode and volume, any named data streams.  When @lte_spec is NULL,
- * the behavior is to extract only all copies of the stream @lte_spec, and in
- * addition use @lte_spec to set the reparse data or create the symbolic link if
- * appropriate.
+ * the extract mode and volume, any named data streams.  When @lte_spec is not
+ * NULL, the behavior is to extract only all copies of the stream @lte_spec, and
+ * in addition use @lte_spec to set the reparse data or create the symbolic link
+ * if appropriate.
  *
  * @path
  *     Path to file to extract (as can be passed to apply_operations
@@ -1221,11 +1221,12 @@ retry:
        raw_fd = topen(name, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0600);
 
        if (raw_fd < 0) {
-               int errno_save = errno;
-               FREE(name);
-               if (errno_save == EEXIST)
+               if (errno == EEXIST) {
+                       FREE(name);
                        goto retry;
+               }
                ERROR_WITH_ERRNO("Failed to open temporary file \"%"TS"\"", name);
+               FREE(name);
                return WIMLIB_ERR_OPEN;
        }
 
@@ -1307,7 +1308,8 @@ need_tmpfile_to_extract(struct wim_lookup_table_entry *lte,
 
 static int
 begin_extract_stream_to_tmpfile(struct wim_lookup_table_entry *lte,
-                               bool is_partial_res, void *_ctx)
+                               bool is_partial_res,
+                               void *_ctx)
 {
        struct apply_ctx *ctx = _ctx;
        int ret;
@@ -1319,10 +1321,7 @@ begin_extract_stream_to_tmpfile(struct wim_lookup_table_entry *lte,
                if (ret)
                        return ret;
 
-               /* Negative return value here means the function was successful,
-                * but the consume_chunk and end_chunk callbacks need not be
-                * called.  */
-               return -1;
+               return BEGIN_STREAM_STATUS_SKIP_STREAM;
        }
 
        DEBUG("Temporary file needed for stream (size=%"PRIu64")", lte->size);
@@ -1389,7 +1388,7 @@ extract_stream_list(struct apply_ctx *ctx)
                };
                return read_stream_list(&ctx->stream_list,
                                        offsetof(struct wim_lookup_table_entry, extraction_list),
-                                       0, &cbs);
+                                       &cbs, VERIFY_STREAM_HASHES);
        } else {
                /* Extract the streams in unsorted order.  */
                struct wim_lookup_table_entry *lte;
@@ -1436,7 +1435,7 @@ read_pwm_stream_header(WIMStruct *pwm, struct wim_lookup_table_entry *lte,
                return 0;
        }
 
-       if (buf.stream_hdr.magic != PWM_STREAM_MAGIC) {
+       if (le64_to_cpu(buf.stream_hdr.magic) != PWM_STREAM_MAGIC) {
                ERROR("Data read on pipe is invalid (expected stream header).");
                return WIMLIB_ERR_INVALID_PIPABLE_WIM;
        }
@@ -1509,7 +1508,7 @@ extract_streams_from_pipe(struct apply_ctx *ctx)
                    && (needed_lte = lookup_resource(lookup_table, found_lte->hash))
                    && (needed_lte->out_refcnt))
                {
-                       char *tmpfile_name = NULL;
+                       tchar *tmpfile_name = NULL;
                        struct wim_lookup_table_entry *lte_override;
                        struct wim_lookup_table_entry tmpfile_lte;