- else
- wimlib_assert(offset + size <= lte->resource_entry.original_size);
-
- switch (lte->resource_location) {
- case RESOURCE_IN_WIM:
- /* The resource is in a WIM file, and its WIMStruct is given by
- * the lte->wim member. The resource may be either compressed
- * or uncompressed. */
- wimlib_assert(lte->wim != NULL);
-
- if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
- fp = wim_get_fp(lte->wim);
- if (!fp)
- return WIMLIB_ERR_OPEN;
- } else {
- wimlib_assert(lte->wim->fp != NULL);
- fp = lte->wim->fp;
- }
-
- ctype = wim_resource_compression_type(lte);
-
- wimlib_assert(ctype != WIM_COMPRESSION_TYPE_NONE ||
- (lte->resource_entry.original_size ==
- lte->resource_entry.size));
-
- if ((flags & WIMLIB_RESOURCE_FLAG_RAW)
- || ctype == WIM_COMPRESSION_TYPE_NONE)
- ret = read_uncompressed_resource(fp,
- lte->resource_entry.offset + offset,
- size, buf);
- else
- ret = read_compressed_resource(fp,
- lte->resource_entry.size,
- lte->resource_entry.original_size,
- lte->resource_entry.offset,
- ctype, size, offset, buf);
- if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
- int ret2 = wim_release_fp(lte->wim, fp);
- if (ret == 0)
- ret = ret2;
- }
- break;
- case RESOURCE_IN_STAGING_FILE:
- case RESOURCE_IN_FILE_ON_DISK:
- /* The resource is in some file on the external filesystem and
- * needs to be read uncompressed */
- wimlib_assert(lte->file_on_disk);
- wimlib_assert(<e->file_on_disk == <e->staging_file_name);
- /* Use existing file pointer if available; otherwise open one
- * temporarily */
- if (lte->file_on_disk_fp) {
- fp = lte->file_on_disk_fp;
- } else {
- fp = fopen(lte->file_on_disk, "rb");
- if (!fp) {
- ERROR_WITH_ERRNO("Failed to open the file "
- "`%s'", lte->file_on_disk);
- ret = WIMLIB_ERR_OPEN;
- break;