- if ((flags & WIMLIB_RESOURCE_FLAG_RAW)
- || ctype == WIMLIB_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);
- #ifdef WITH_FUSE
- if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
- int ret2 = wim_release_fp(lte->wim, fp);
- if (ret == 0)
- ret = ret2;
- }
- #endif
- 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;
- }
- }
- ret = read_uncompressed_resource(fp, offset, size, buf);
- if (fp != lte->file_on_disk_fp)
- fclose(fp);
- break;
- case RESOURCE_IN_ATTACHED_BUFFER:
- /* The resource is directly attached uncompressed in an
- * in-memory buffer. */
- wimlib_assert(lte->attached_buffer != NULL);
- memcpy(buf, lte->attached_buffer + offset, size);
- break;
-#ifdef WITH_NTFS_3G
- case RESOURCE_IN_NTFS_VOLUME:
- wimlib_assert(lte->ntfs_loc != NULL);
- wimlib_assert(lte->attr != NULL);
- if (lte->ntfs_loc->is_reparse_point)
- offset += 8;
- if (ntfs_attr_pread(lte->attr, offset, size, buf) != size) {
- ERROR_WITH_ERRNO("Error reading NTFS attribute "
- "at `%s'",
- lte->ntfs_loc->path_utf8);
- ret = WIMLIB_ERR_NTFS_3G;