]> wimlib.net Git - wimlib/blobdiff - include/wimlib/resource.h
Don't create unnecessary temporary files
[wimlib] / include / wimlib / resource.h
index 9694259d844082bbcf3ebe0acbeb18aa655a3da1..ae0775536b726e138000cfc4fd77dcbbd8feba48 100644 (file)
@@ -52,6 +52,13 @@ struct wim_resource_spec {
 
        /* Temporary flag.  */
        u32 raw_copy_ok : 1;
+
+       /* Compression type of this resource.  */
+       u32 compression_type : 22;
+
+       /* Compression chunk size of this resource.  Irrelevant if the resource
+        * is uncompressed.  */
+       u32 chunk_size;
 };
 
 /* On-disk version of a WIM resource header.  */
@@ -159,8 +166,8 @@ struct alt_chunk_table_header_disk {
 
        /* Compression format used for compressed chunks:
         * 0 = None
-        * 1 = LZX
-        * 2 = XPRESS
+        * 1 = XPRESS
+        * 2 = LZX
         * 3 = LZMS
         *
         * This overrides the compression type specified by the WIM header.  */
@@ -170,6 +177,15 @@ struct alt_chunk_table_header_disk {
         * the chunks (4 bytes per entry).  */
 } _packed_attribute;
 
+static inline unsigned int
+get_chunk_entry_size(u64 res_size, bool is_alt)
+{
+       if (res_size <= UINT32_MAX || is_alt)
+               return 4;
+       else
+               return 8;
+}
+
 /* Functions to read streams  */
 
 extern int
@@ -187,6 +203,10 @@ extern int
 wim_reshdr_to_data(const struct wim_reshdr *reshdr,
                   WIMStruct *wim, void **buf_ret);
 
+extern int
+wim_reshdr_to_hash(const struct wim_reshdr *reshdr, WIMStruct *wim,
+                  u8 hash[SHA1_HASH_SIZE]);
+
 extern int
 skip_wim_stream(struct wim_lookup_table_entry *lte);
 
@@ -196,10 +216,9 @@ skip_wim_stream(struct wim_lookup_table_entry *lte);
  * @lte:
  *     Stream that is about to be read.
  *
- * @is_partial_res:
- *     Set to true if the stream is just one of several being read from a
- *     single pack and therefore would be extra expensive to read
- *     independently.
+ * @flags:
+ *     Bitwise OR of BEGIN_STREAM_FLAG_PARTIAL_RESOURCE and/or
+ *     BEGIN_STREAM_FLAG_WHOLE_STREAM.
  *
  * @ctx:
  *     User-provided context.
@@ -210,9 +229,17 @@ skip_wim_stream(struct wim_lookup_table_entry *lte);
  * (without calling @consume_chunk or @end_stream).
  */
 typedef int (*read_stream_list_begin_stream_t)(struct wim_lookup_table_entry *lte,
-                                              bool is_partial_res,
+                                              u32 flags,
                                               void *ctx);
 
+/* Set to true if the stream is just one of several being read from a single
+ * pack and therefore would be extra expensive to read independently.  */
+#define BEGIN_STREAM_FLAG_PARTIAL_RESOURCE     0x00000001
+
+/* This is purely advisory and indicates that the entire stream data will be
+ * provided in one call to consume_chunk().  */
+#define BEGIN_STREAM_FLAG_WHOLE_STREAM         0x00000002
+
 #define BEGIN_STREAM_STATUS_SKIP_STREAM        -1
 
 /*
@@ -280,6 +307,10 @@ extern int
 extract_stream_to_fd(struct wim_lookup_table_entry *lte,
                     struct filedes *fd, u64 size);
 
+extern int
+extract_full_stream_to_fd(struct wim_lookup_table_entry *lte,
+                         struct filedes *fd);
+
 extern int
 extract_chunk_to_fd(const void *chunk, size_t size, void *_fd_p);